Skip to content

Commit

Permalink
fix: fmt scalar view values
Browse files Browse the repository at this point in the history
Signed-off-by: Ion Koutsouris <[email protected]>
  • Loading branch information
ion-elgreco authored and rtyler committed Jan 15, 2025
1 parent 281825e commit 62b108a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/core/src/delta_datafusion/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,16 @@ impl fmt::Display for ScalarValueFormat<'_> {
},
None => write!(f, "NULL")?,
},
ScalarValue::Utf8(e) | ScalarValue::LargeUtf8(e) => match e {
Some(e) => write!(f, "'{}'", escape_quoted_string(e, '\''))?,
None => write!(f, "NULL")?,
},
ScalarValue::Utf8(e) | ScalarValue::LargeUtf8(e) | ScalarValue::Utf8View(e) => {
match e {
Some(e) => write!(f, "'{}'", escape_quoted_string(e, '\''))?,
None => write!(f, "NULL")?,
}
}
ScalarValue::Binary(e)
| ScalarValue::FixedSizeBinary(_, e)
| ScalarValue::LargeBinary(e) => match e {
| ScalarValue::LargeBinary(e)
| ScalarValue::BinaryView(e) => match e {
Some(l) => write!(
f,
"decode('{}', 'hex')",
Expand Down
25 changes: 25 additions & 0 deletions python/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,3 +1268,28 @@ def test_merge_on_decimal_3033(tmp_path):
string_predicate
== "timestamp BETWEEN arrow_cast('2024-03-20T12:30:00.000000', 'Timestamp(Microsecond, None)') AND arrow_cast('2024-03-20T12:30:00.000000', 'Timestamp(Microsecond, None)') AND altitude BETWEEN '1505'::decimal(4, 1) AND '1505'::decimal(4, 1)"
)


@pytest.mark.polars
def test_merge(tmp_path: pathlib.Path):
import polars as pl
from polars.testing import assert_frame_equal

pl.DataFrame({"id": ["a", "b", "c"], "val": [4.0, 5.0, 6.0]}).write_delta(
tmp_path, mode="overwrite"
)

df = pl.DataFrame({"id": ["a", "b", "c", "d"], "val": [4.1, 5, 6.1, 7]})

df.write_delta(
tmp_path,
mode="merge",
delta_merge_options={
"predicate": "tgt.id = src.id",
"source_alias": "src",
"target_alias": "tgt",
},
).when_matched_update_all().when_not_matched_insert_all().execute()

new_df = pl.read_delta(str(tmp_path))
assert_frame_equal(df, new_df, check_row_order=False)

0 comments on commit 62b108a

Please sign in to comment.