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: expression with dates to string conversation #3019

Merged
merged 3 commits into from
Nov 22, 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
14 changes: 13 additions & 1 deletion crates/core/src/delta_datafusion/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ impl<'a> fmt::Display for ScalarValueFormat<'a> {
ScalarValue::Date32(e) => match e {
Some(e) => write!(
f,
"{}",
"'{}'::date",
NaiveDate::from_num_days_from_ce_opt(EPOCH_DAYS_FROM_CE + (*e)).ok_or(Error)?
)?,
None => write!(f, "NULL")?,
Expand Down Expand Up @@ -875,6 +875,18 @@ mod test {
)
)),
},
ParseTest {
expr: col("_date").eq(lit(ScalarValue::Date32(Some(18262)))),
expected: "_date = '2020-01-01'::date".to_string(),
override_expected_expr: Some(col("_date").eq(
Expr::Cast(
Cast {
expr: Box::from(lit("2020-01-01")),
data_type: arrow_schema::DataType::Date32
}
)
)),
},
];

let session: SessionContext = DeltaSessionContext::default().into();
Expand Down
5 changes: 4 additions & 1 deletion python/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,10 @@ def test_merge_date_partitioned_2344(tmp_path: pathlib.Path):

assert last_action["operation"] == "MERGE"
assert result == data
assert last_action["operationParameters"].get("predicate") == "2022-02-01 = date"
assert (
last_action["operationParameters"].get("predicate")
== "'2022-02-01'::date = date"
)


@pytest.mark.parametrize(
Expand Down
Loading