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(rust,python): better-characterise NotFound exceptions #6670

Merged

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Feb 4, 2023

Closes #6647.

Rather than a single NotFound exception, we can now characterise this error by what was not found:

  • ColumnNotFound
  • SchemaFieldNotFound
  • StructFieldNotFound

Example

df = pl.struct(
    [pl.Series("a", [1,2,3]), pl.Series("b", ["a","b","c"])], eager=True
).to_frame().with_columns( pl.lit(0).alias("b") )

Before (exception lacks context)

df.select(pl.col("c").struct.field("c"))   << which "c" causes the error?
# NotFoundError: c

df.select(pl.col("a").struct.field("c"))
# NotFoundError: c

After (exception is specific)

df.select(pl.col("c").struct.field("c"))
# ColumnNotFoundError: c

df.select(pl.col("a").struct.field("c"))
# StructFieldNotFoundError: c

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Feb 4, 2023
@ritchie46
Copy link
Member

Nice addition!

@ritchie46 ritchie46 merged commit 3a6c999 into pola-rs:master Feb 4, 2023
@alexander-beedie alexander-beedie deleted the contextualise-notfound-exceptions branch February 4, 2023 17:10
Vincenthays pushed a commit to Vincenthays/polars that referenced this pull request Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance/extend NotFound exception to indicate _what_ was not found
2 participants