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

Improve error message when filtering on non-existant partition columns #1218

Closed
wjones127 opened this issue Mar 12, 2023 · 0 comments · Fixed by #1221
Closed

Improve error message when filtering on non-existant partition columns #1218

wjones127 opened this issue Mar 12, 2023 · 0 comments · Fixed by #1221
Labels
binding/python Issues for the Python package binding/rust Issues for the Rust crate enhancement New feature or request good first issue Good for newcomers

Comments

@wjones127
Copy link
Collaborator

wjones127 commented Mar 12, 2023

Description

When I tried filtering with the partition filters on date columns, I got the error:

When I tried filtering with partition filters on a table that didn't have any partition columns, I got the error:

Invalid partition filter found: [PartitionFilter { key: "observation_date", value: Equal("2023-01-03") }].

We should improve this error message to say something like:

Tried to filter partitions on column "observation_date", but that isn't one of the partition columns. This table has no partition columns.
@wjones127 wjones127 added enhancement New feature or request good first issue Good for newcomers binding/python Issues for the Python package binding/rust Issues for the Rust crate labels Mar 12, 2023
@wjones127 wjones127 changed the title Support partition filters on date columns Improve error message when filtering on non-existant partition columns Mar 12, 2023
wjones127 pushed a commit that referenced this issue Mar 24, 2023
# Description
Updates the error message when trying to use a partition filter with a
column that is not partitioned.

Code to trigger the error (adapted from #1219):
```python
from datetime import date

import numpy as np
import numpy.random
import pandas as pd
from deltalake import DeltaTable, write_deltalake

nrows = 9
data = pd.DataFrame(
    {
        "year": np.repeat(2023, nrows),
        "month": np.repeat([1, 2, 3], nrows / 3),
        "values": numpy.random.normal(size=nrows),
    }
)
table_path = "tables/monthly"
write_deltalake(
    table_path,
    data,
    partition_by=["year", "month"],
    mode="overwrite",
)

nrows = 4
new_data = pd.DataFrame(
    {
        "year": np.repeat(2023, nrows),
        "month": np.repeat([4], nrows),
        "values": numpy.random.normal(size=nrows) + 10,
    }
)

write_deltalake(
    table_path,
    new_data,
    mode="overwrite",
    partition_filters=[("values", "=", "1")],
)
DeltaTable(table_path).to_pandas()
```

# Related Issue(s)
closes #1218 

# Documentation

<!---
Share links to useful documentation
--->

---------

Signed-off-by: Marijn Valk <marijncv@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/python Issues for the Python package binding/rust Issues for the Rust crate enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant