Jimexist edited a comment on issue #1179:
URL:
https://github.com/apache/arrow-datafusion/issues/1179#issuecomment-953082109
> The source of the problem is here:
>
> ```
> SQLExpr::Value(Value::Null) => {
> Ok(Expr::Literal(ScalarValue::Utf8(None)))
> }
> ```
>
> I would propose:
>
> * To introduce `ScalarValue::Null` and use that instead for `Value::Null`.
> * Return `DataType::Null` as type for `ScalarValue::Null`
> * Implement the rest of changes in coercion as needed.
i wonder how this line up with typed nulls for other enum cases.
or, could we actually get rid of the `Option` wrapping for other types, and
keep this null enum case with wrapper type instead?
```diff
diff --git a/datafusion/src/scalar.rs b/datafusion/src/scalar.rs
index 00586bf55..0ce87195c 100644
--- a/datafusion/src/scalar.rs
+++ b/datafusion/src/scalar.rs
@@ -37,32 +37,34 @@ use std::{convert::TryFrom, fmt, iter::repeat,
sync::Arc};
/// This is the single-valued counter-part of arrow’s `Array`.
#[derive(Clone)]
pub enum ScalarValue {
+ /// a typed or untyped null
+ Null(Option<DataType>),
/// true or false value
- Boolean(Option<bool>),
+ Boolean(bool)
/// 32bit float
- Float32(Option<f32>),
+ Float32(f32)
/// 64bit float
- Float64(Option<f64>),
+ Float64(f64)
/// signed 8bit int
- Int8(Option<i8>),
+ Int8(i8)
/// signed 16bit int
- Int16(Option<i16>),
+ Int16(i16)
/// signed 32bit int
- Int32(Option<i32>),
+ Int32(i32)
/// signed 64bit int
- Int64(Option<i64>),
+ Int64(i64)
/// unsigned 8bit int
- UInt8(Option<u8>),
+ UInt8(u8)
/// unsigned 16bit int
- UInt16(Option<u16>),
+ UInt16(u16)
/// unsigned 32bit int
- UInt32(Option<u32>),
+ UInt32(u32)
/// unsigned 64bit int
- UInt64(Option<u64>),
+ UInt64(u64)
/// utf-8 encoded string.
- Utf8(Option<String>),
+ Utf8(String)
/// utf-8 encoded string representing a LargeString's arrow type.
- LargeUtf8(Option<String>),
+ LargeUtf8(String)
/// binary
Binary(Option<Vec<u8>>),
/// large binary
@@ -71,21 +73,21 @@ pub enum ScalarValue {
#[allow(clippy::box_vec)]
List(Option<Box<Vec<ScalarValue>>>, Box<DataType>),
/// Date stored as a signed 32bit int
- Date32(Option<i32>),
+ Date32(i32)
/// Date stored as a signed 64bit int
- Date64(Option<i64>),
+ Date64(i64)
/// Timestamp Second
- TimestampSecond(Option<i64>),
+ TimestampSecond(i64)
/// Timestamp Milliseconds
- TimestampMillisecond(Option<i64>),
+ TimestampMillisecond(i64)
/// Timestamp Microseconds
- TimestampMicrosecond(Option<i64>),
+ TimestampMicrosecond(i64)
/// Timestamp Nanoseconds
- TimestampNanosecond(Option<i64>),
+ TimestampNanosecond(i64)
/// Interval with YearMonth unit
- IntervalYearMonth(Option<i32>),
+ IntervalYearMonth(i32)
/// Interval with DayTime unit
- IntervalDayTime(Option<i64>),
+ IntervalDayTime(i64)
/// struct of nested ScalarValue (boxed to reduce size_of(ScalarValue))
#[allow(clippy::box_vec)]
Struct(Option<Box<Vec<ScalarValue>>>, Box<Vec<Field>>),
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]