From 62b108ac46e6a98e2fd29be0eb6620f6eb6fde69 Mon Sep 17 00:00:00 2001 From: Ion Koutsouris <15728914+ion-elgreco@users.noreply.github.com> Date: Tue, 14 Jan 2025 21:39:32 +0100 Subject: [PATCH] fix: fmt scalar view values Signed-off-by: Ion Koutsouris <15728914+ion-elgreco@users.noreply.github.com> --- crates/core/src/delta_datafusion/expr.rs | 13 +++++++----- python/tests/test_merge.py | 25 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/crates/core/src/delta_datafusion/expr.rs b/crates/core/src/delta_datafusion/expr.rs index b117d49bb4..6d544fb7cf 100644 --- a/crates/core/src/delta_datafusion/expr.rs +++ b/crates/core/src/delta_datafusion/expr.rs @@ -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')", diff --git a/python/tests/test_merge.py b/python/tests/test_merge.py index b9ac935753..69eb73ebc6 100644 --- a/python/tests/test_merge.py +++ b/python/tests/test_merge.py @@ -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)