Skip to content

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

@gforsyth

Description

@gforsyth

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions