-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(table-api): unify exception type for all backends to TableNotFound
when a table does not exist
#9695
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple changes needed, thanks for doing this!
ibis/backends/druid/__init__.py
Outdated
.sql(self.dialect) | ||
) | ||
except ProgrammingError as e: | ||
if re.search(r"\bINVALID_INPUT\b", str(e)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to get anything better than this matching, if anyone has any ideas, suggestions welcome
ibis/backends/flink/__init__.py
Outdated
except Py4JJavaError as e: | ||
# This seems to msg specific but not sure what a good work around is | ||
if re.search( | ||
rf"Table `{re.escape(table_name)}` was not found", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, but I'm not sure if there is a better way to get the error matching here. Suggestions welcomed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpcloud do we think this is alright for flink? It's a bit specific but I didn't find an alternative, If so I'll remove the comment here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like there's some poking around the java object that could be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried multiple thinks, I wasn't able to land in anything better than this, I tried inspecting e.java_exception
to get the getSQLState
but I wasn't able. Maybe I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and changed this to catch the error, and then check for table existence instead of matching.
INVALID_INPUT
is way too general of a string to match on in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was commenting on the druid one...this is the flink one.
I think this is good to get a first path of review. I left some comments on the cases where the exception caught is not great/pretty and we are doing some for of string matching. If anyone has better ideas for those, suggestions are more than welcome. Notes/help needed:
one solution is to add also pytestmark = [
pytest.mark.notimpl(
["druid"], raises=(com.OperationNotDefinedError, com.TableNotFound, PyDruidProgrammingError)
)
] is this the right approach? |
Co-authored-by: Phillip Cloud <[email protected]>
Co-authored-by: Phillip Cloud <[email protected]>
3d01efc
to
9dde9d4
Compare
The PySpark error class import needs an There are some examples around the codebase for this that were recently added. |
Added a Snowflake implementation. It's ... something. |
I added this to the 10.0 milestone as it will have breaking changes for those using Ibis as a library. |
Ok, BigQuery implementation is up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple more missing from e
s
ibis/backends/pyspark/__init__.py
Outdated
if e.getErrorClass() == "TABLE_OR_VIEW_NOT_FOUND": | ||
raise com.TableNotFound(table_name) from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if e.getErrorClass() == "TABLE_OR_VIEW_NOT_FOUND": | |
raise com.TableNotFound(table_name) from e | |
if e.getErrorClass() == "TABLE_OR_VIEW_NOT_FOUND": | |
raise com.TableNotFound(table_name) from e | |
raise |
You still need to raise for any other AnalysisException
that isn't handled by the error class check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this check doesn't seem to be working for PySpark 3.3.3, I'm looking into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commit.
@@ -126,6 +126,21 @@ def _get_schema_using_query(self, query: str) -> sch.Schema: | |||
schema[name] = dtype | |||
return sch.Schema(schema) | |||
|
|||
def _table_exists(self, name: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, thanks for adding this. It's way more clear.
I think this is good to go. What an absolute hellscape this problem is. Thanks for powering through @ncclementi! |
Thanks @cpcloud, great job you too! Thanks for the pairing and troubleshooting. When we are ready for 10.0 we can rebase and deal with conflicts if we have to. |
Hey y'all I tried to rebase this locally and did not go well 😞 so I'd need some help getting this one up to mark to be able to consolidate changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple small things, but otherwise this LGTM.
TableNotFound
when a table does not exist
…otFound` when a table does not exist (ibis-project#9695) Co-authored-by: Phillip Cloud <[email protected]> Co-authored-by: Gil Forsyth <[email protected]>
Closes #9468
TODO:
!r
to the instance of the exception.BREAKING CHANGE: Missing tables now all raise a single Ibis exception. Library code that catches backend-specific exceptions to handle missing tables will need to be adjusted to use
TableNotFound
instead.