Skip to content

Commit 8ca5fc1

Browse files
committed
feat(12118): logical plan support for BinaryView
1 parent b17ae25 commit 8ca5fc1

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

datafusion/substrait/src/logical_plan/consumer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,7 @@ fn from_substrait_type(
14321432
r#type::Kind::Binary(binary) => match binary.type_variation_reference {
14331433
DEFAULT_CONTAINER_TYPE_VARIATION_REF => Ok(DataType::Binary),
14341434
LARGE_CONTAINER_TYPE_VARIATION_REF => Ok(DataType::LargeBinary),
1435+
VIEW_CONTAINER_TYPE_VARIATION_REF => Ok(DataType::BinaryView),
14351436
v => not_impl_err!(
14361437
"Unsupported Substrait type variation {v} of type {s_kind:?}"
14371438
),
@@ -1770,6 +1771,7 @@ fn from_substrait_literal(
17701771
LARGE_CONTAINER_TYPE_VARIATION_REF => {
17711772
ScalarValue::LargeBinary(Some(b.clone()))
17721773
}
1774+
VIEW_CONTAINER_TYPE_VARIATION_REF => ScalarValue::BinaryView(Some(b.clone())),
17731775
others => {
17741776
return substrait_err!("Unknown type variation reference {others}");
17751777
}

datafusion/substrait/src/logical_plan/producer.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,12 @@ fn to_substrait_type(
14621462
nullability,
14631463
})),
14641464
}),
1465+
DataType::BinaryView => Ok(substrait::proto::Type {
1466+
kind: Some(r#type::Kind::Binary(r#type::Binary {
1467+
type_variation_reference: VIEW_CONTAINER_TYPE_VARIATION_REF,
1468+
nullability,
1469+
})),
1470+
}),
14651471
DataType::Utf8 => Ok(substrait::proto::Type {
14661472
kind: Some(r#type::Kind::String(r#type::String {
14671473
type_variation_reference: DEFAULT_CONTAINER_TYPE_VARIATION_REF,
@@ -2361,6 +2367,7 @@ mod test {
23612367
round_trip_type(DataType::Binary)?;
23622368
round_trip_type(DataType::FixedSizeBinary(10))?;
23632369
round_trip_type(DataType::LargeBinary)?;
2370+
round_trip_type(DataType::BinaryView)?;
23642371
round_trip_type(DataType::Utf8)?;
23652372
round_trip_type(DataType::LargeUtf8)?;
23662373
round_trip_type(DataType::Utf8View)?;

datafusion/substrait/tests/cases/roundtrip_logical_plan.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ async fn all_type_literal() -> Result<()> {
716716
date32_col = arrow_cast('2020-01-01', 'Date32') AND
717717
binary_col = arrow_cast('binary', 'Binary') AND
718718
large_binary_col = arrow_cast('large_binary', 'LargeBinary') AND
719+
view_binary_col = arrow_cast('binary_view', 'BinaryView') AND
719720
utf8_col = arrow_cast('utf8', 'Utf8') AND
720721
large_utf8_col = arrow_cast('large_utf8', 'LargeUtf8') AND
721722
view_utf8_col = arrow_cast('utf8_view', 'Utf8View');",
@@ -1232,6 +1233,7 @@ async fn create_all_type_context() -> Result<SessionContext> {
12321233
Field::new("date64_col", DataType::Date64, true),
12331234
Field::new("binary_col", DataType::Binary, true),
12341235
Field::new("large_binary_col", DataType::LargeBinary, true),
1236+
Field::new("view_binary_col", DataType::BinaryView, true),
12351237
Field::new("fixed_size_binary_col", DataType::FixedSizeBinary(42), true),
12361238
Field::new("utf8_col", DataType::Utf8, true),
12371239
Field::new("large_utf8_col", DataType::LargeUtf8, true),

0 commit comments

Comments
 (0)