Skip to content

Commit 700fe41

Browse files
committed
feat(12118): physical plan support for BinaryView
1 parent 8ca5fc1 commit 700fe41

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

datafusion/substrait/src/physical_plan/consumer.rs

+12
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ fn to_field(name: &String, r#type: &Type) -> Result<Field> {
192192
),
193193
}
194194
}
195+
Kind::Binary(binary) => {
196+
nullable = is_nullable(binary.nullability);
197+
match binary.type_variation_reference {
198+
DEFAULT_CONTAINER_TYPE_VARIATION_REF => Ok(DataType::Binary),
199+
LARGE_CONTAINER_TYPE_VARIATION_REF => Ok(DataType::LargeBinary),
200+
VIEW_CONTAINER_TYPE_VARIATION_REF => Ok(DataType::BinaryView),
201+
_ => substrait_err!(
202+
"Invalid type variation found for substrait binary type class: {}",
203+
binary.type_variation_reference
204+
),
205+
}
206+
}
195207
_ => substrait_err!(
196208
"Unsupported kind: {:?} in the type with name {}",
197209
kind,

datafusion/substrait/src/physical_plan/producer.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::collections::HashMap;
2323
use substrait::proto::expression::mask_expression::{StructItem, StructSelect};
2424
use substrait::proto::expression::MaskExpression;
2525
use substrait::proto::r#type::{
26-
Boolean, Fp64, Kind, Nullability, String as SubstraitString, Struct, I64,
26+
Binary, Boolean, Fp64, Kind, Nullability, String as SubstraitString, Struct, I64,
2727
};
2828
use substrait::proto::read_rel::local_files::file_or_files::ParquetReadOptions;
2929
use substrait::proto::read_rel::local_files::file_or_files::{FileFormat, PathType};
@@ -176,6 +176,24 @@ fn to_substrait_type(data_type: &DataType, nullable: bool) -> Result<Type> {
176176
nullability,
177177
})),
178178
}),
179+
DataType::Binary => Ok(Type {
180+
kind: Some(Kind::Binary(Binary {
181+
type_variation_reference: DEFAULT_CONTAINER_TYPE_VARIATION_REF,
182+
nullability,
183+
})),
184+
}),
185+
DataType::LargeBinary => Ok(Type {
186+
kind: Some(Kind::Binary(Binary {
187+
type_variation_reference: LARGE_CONTAINER_TYPE_VARIATION_REF,
188+
nullability,
189+
})),
190+
}),
191+
DataType::BinaryView => Ok(Type {
192+
kind: Some(Kind::Binary(Binary {
193+
type_variation_reference: VIEW_CONTAINER_TYPE_VARIATION_REF,
194+
nullability,
195+
})),
196+
}),
179197
_ => Err(DataFusionError::Substrait(format!(
180198
"Logical type {data_type} not implemented as substrait type"
181199
))),

0 commit comments

Comments
 (0)