Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: jayzhan211 <[email protected]>
  • Loading branch information
jayzhan211 committed Nov 21, 2023
1 parent 716977b commit 6727b92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
19 changes: 6 additions & 13 deletions datafusion/common/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2933,19 +2933,12 @@ impl fmt::Display for ScalarValue {
None => write!(f, "NULL")?,
},
ScalarValue::List(arr) | ScalarValue::FixedSizeList(arr) => {
// TODO: Remove NullArray
// There are NullArray(0) currently, so we need to check the length
if arr.len() == 0 {
write!(f, "[]")?
} else {
let options = FormatOptions::default().with_display_error(true);
// TODO: No way to map to fmt::Error yet
let formatter = ArrayFormatter::try_new(arr, &options)
.map_err(DataFusionError::ArrowError)
.unwrap();
let value_formatter = formatter.value(0);
write!(f, "{value_formatter}")?
}
// ScalarValue List should always have a single element
assert_eq!(arr.len(), 1);
let options = FormatOptions::default().with_display_error(true);
let formatter = ArrayFormatter::try_new(arr, &options).unwrap();
let value_formatter = formatter.value(0);
write!(f, "{value_formatter}")?
}
ScalarValue::Date32(e) => format_option!(f, e)?,
ScalarValue::Date64(e) => format_option!(f, e)?,
Expand Down
10 changes: 10 additions & 0 deletions datafusion/sqllogictest/test_files/explain.slt
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,13 @@ Projection: List([[1, 2, 3], [4, 5, 6]]) AS make_array(make_array(Int64(1),Int64
physical_plan
ProjectionExec: expr=[[[1, 2, 3], [4, 5, 6]] as make_array(make_array(Int64(1),Int64(2),Int64(3)),make_array(Int64(4),Int64(5),Int64(6)))]
--EmptyExec: produce_one_row=true

query TT
explain select [[1, 2, 3], [4, 5, 6]];
----
logical_plan
Projection: List([[1, 2, 3], [4, 5, 6]]) AS make_array(make_array(Int64(1),Int64(2),Int64(3)),make_array(Int64(4),Int64(5),Int64(6)))
--EmptyRelation
physical_plan
ProjectionExec: expr=[[[1, 2, 3], [4, 5, 6]] as make_array(make_array(Int64(1),Int64(2),Int64(3)),make_array(Int64(4),Int64(5),Int64(6)))]
--EmptyExec: produce_one_row=true

0 comments on commit 6727b92

Please sign in to comment.