Skip to content
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
6 changes: 6 additions & 0 deletions datafusion/proto/proto/datafusion.proto
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,11 @@ message StructValue {
repeated Field fields = 3;
}

message ScalarFixedSizeBinary{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: should we follow the actual definition and put the length as the first field (it shouldn't matter much, except aesthetically but I think it keeps the declaration in here and the struct in scalar value consistent).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for feedback. While I was looking for similar definitons, I came acrros to this and implement it in this way. https://github.com/apache/arrow-datafusion/blob/48f73c6af3b0cc747c38b4a9c7a610f4630e8736/datafusion/proto/proto/datafusion.proto#L711-L714

However, I am open to fix in a way to comply with preferred code style. If this is the only thing that needs to be changed, I will create a commit.

bytes values = 1;
int32 length = 2;
}

message ScalarValue{
// was PrimitiveScalarType null_value = 19;
reserved 19;
Expand Down Expand Up @@ -808,6 +813,7 @@ message ScalarValue{
int64 time64_value = 30;
IntervalMonthDayNanoValue interval_month_day_nano = 31;
StructValue struct_value = 32;
ScalarFixedSizeBinary fixed_size_binary_value = 34;
}
}

Expand Down
3 changes: 3 additions & 0 deletions datafusion/proto/src/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,9 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {

Self::Struct(values, Box::new(fields))
}
Value::FixedSizeBinaryValue(v) => {
Self::FixedSizeBinary(v.length, Some(v.clone().values))
}
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions datafusion/proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ mod roundtrip_tests {
Field::new("a", DataType::Boolean, false),
]),
),
ScalarValue::FixedSizeBinary(
b"bar".to_vec().len() as i32,
Some(b"bar".to_vec()),
),
ScalarValue::FixedSizeBinary(0, None),
ScalarValue::FixedSizeBinary(5, None),
];

for test_case in should_pass.into_iter() {
Expand Down
11 changes: 8 additions & 3 deletions datafusion/proto/src/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,14 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue {
Value::LargeBinaryValue(s.to_owned())
})
}
scalar::ScalarValue::FixedSizeBinary(_, _) => Err(Error::General(
"FixedSizeBinary is not yet implemented".to_owned(),
)),
scalar::ScalarValue::FixedSizeBinary(length, val) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

create_proto_scalar(val, &data_type, |s| {
Value::FixedSizeBinaryValue(protobuf::ScalarFixedSizeBinary {
values: s.to_owned(),
length: *length,
})
})
}

datafusion::scalar::ScalarValue::Time64(v) => {
create_proto_scalar(v, &data_type, |v| Value::Time64Value(*v))
Expand Down