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

fix(rust): scan schema fix for predicate #2869

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/core/src/operations/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ async fn execute_non_empty_expr(
let input_dfschema: DFSchema = df_schema.as_ref().clone().try_into()?;

let scan_config = DeltaScanConfigBuilder::new()
.with_schema(df_schema)
.with_schema(snapshot.input_schema()?)
.build(snapshot)?;

let scan = DeltaScanBuilder::new(snapshot, log_store.clone(), &state)
Expand Down
38 changes: 38 additions & 0 deletions python/tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,3 +1850,41 @@ def test_empty_dataset_write(tmp_path: pathlib.Path, sample_data: pa.Table):
empty_dataset = dataset(empty_arrow_table)
with pytest.raises(DeltaError, match="No data source supplied to write command"):
write_deltalake(tmp_path, empty_dataset, mode="append")


@pytest.mark.pandas
def test_predicate_out_of_bounds(tmp_path: pathlib.Path):
"""See <https://github.com/delta-io/delta-rs/issues/2867>"""
import pandas as pd

data = [
(datetime(2024, 7, 31, 9, 30, 0), "AAPL", "20240731", 100, 11.1),
(datetime(2024, 7, 31, 9, 30, 0), "GOOG", "20240731", 200, 11.1),
]
columns = ["ts", "ins", "date", "f1", "f2"]
df = pd.DataFrame(data, columns=columns)

predicate = "date == 20240731"
write_deltalake(
table_or_uri=tmp_path,
data=df,
partition_by="date",
mode="overwrite",
schema_mode="merge",
predicate=predicate,
)

data = [
(datetime(2024, 7, 31, 9, 30, 0), "AAPL", "20240731", 666, 666),
(datetime(2024, 7, 31, 9, 30, 0), "GOOG", "20240731", 777, 777),
]
columns = ["ts", "ins", "date", "fb", "fc"]
df = pd.DataFrame(data, columns=columns)
write_deltalake(
table_or_uri=tmp_path,
data=df,
partition_by="date",
mode="overwrite",
schema_mode="merge",
predicate=predicate,
)
Loading