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
4 changes: 1 addition & 3 deletions datafusion/proto/src/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,7 @@ impl TryFrom<&protobuf::PrimitiveScalarType> for ScalarValue {
use protobuf::PrimitiveScalarType;

Ok(match scalar {
PrimitiveScalarType::Null => {
return Err(proto_error("Untyped null is an invalid scalar value"));
}
PrimitiveScalarType::Null => Self::Null,
PrimitiveScalarType::Bool => Self::Boolean(None),
PrimitiveScalarType::Uint8 => Self::UInt8(None),
PrimitiveScalarType::Int8 => Self::Int8(None),
Expand Down
20 changes: 20 additions & 0 deletions datafusion/proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,26 @@ mod roundtrip_tests {
roundtrip_expr_test(test_expr, ctx);
}

#[test]
fn roundtrip_case_with_null() {
let test_expr = Expr::Case {
expr: Some(Box::new(lit(1.0_f32))),
when_then_expr: vec![(Box::new(lit(2.0_f32)), Box::new(lit(3.0_f32)))],
else_expr: Some(Box::new(Expr::Literal(ScalarValue::Null))),
};

let ctx = SessionContext::new();
roundtrip_expr_test(test_expr, ctx);
}

#[test]
fn roundtrip_null_literal() {
let test_expr = Expr::Literal(ScalarValue::Null);

let ctx = SessionContext::new();
roundtrip_expr_test(test_expr, ctx);
}

#[test]
fn roundtrip_cast() {
let test_expr = Expr::Cast {
Expand Down
3 changes: 3 additions & 0 deletions datafusion/proto/src/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,9 @@ impl TryFrom<&ScalarValue> for protobuf::ScalarValue {
Value::IntervalDaytimeValue(*s)
})
}
ScalarValue::Null => protobuf::ScalarValue {
value: Some(Value::NullValue(PrimitiveScalarType::Null as i32)),
},
_ => {
return Err(Error::invalid_scalar_value(val));
}
Expand Down