Skip to content
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

feat: better exception when table doesn't exist #796

Closed
gforsyth opened this issue Aug 5, 2024 · 0 comments · Fixed by #851
Closed

feat: better exception when table doesn't exist #796

gforsyth opened this issue Aug 5, 2024 · 0 comments · Fixed by #851
Labels
enhancement New feature or request

Comments

@gforsyth
Copy link

gforsyth commented Aug 5, 2024

Ibis supports datafusion as one of our backends, and we make use of datafusion-python in service of that.

One of the thornier issues we face right is that Datafusion returns Exception as the exception type when a table isn't found.

The exception message is more specific, but on the Python side, it is generally not a good move to catch a bare Exception -- and we're in the position of having to catch it, then parse the exception message, then continue as appropriate.

[ins] In [5]: from datafusion import SessionContext

[ins] In [6]: c = SessionContext()

[ins] In [7]: c.table("notatable")
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 c.table("notatable")

Exception: DataFusion error: Plan("No table named 'notatable'")

conversely, attempting to look at a catalog that doesn't exist:

[ins] In [9]: c.catalog("nope")
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[9], line 1
----> 1 c.catalog("nope")

KeyError: "Catalog with name nope doesn't exist."

That's much nicer.

Describe the solution you'd like
Either a datafusion-specific error message, or raise a KeyError (or some other more specific error type.

Describe alternatives you've considered
Catching and parsing, as described above, but it's suboptimal.

Thanks!

@gforsyth gforsyth added the enhancement New feature or request label Aug 5, 2024
mesejo added a commit to mesejo/arrow-datafusion-python that referenced this issue Sep 2, 2024
allinux pushed a commit to allinux/datafusion-python that referenced this issue Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant