Skip to content

Apache DataFusion SQL Query Engine

ARROW-10769: [Rust] Revert "ARROW-10656: [Rust] Use DataType comparison without values"

Neville Dipaleb9e54d2080a8
diff --git a/rust/datafusion/src/physical_plan/distinct_expressions.rs b/rust/datafusion/src/physical_plan/distinct_expressions.rs
index a441c0b76c..bbccc3be6e 100644
--- a/rust/datafusion/src/physical_plan/distinct_expressions.rs
+++ b/rust/datafusion/src/physical_plan/distinct_expressions.rs
@@ -22,7 +22,7 @@ use std::fmt::Debug;
use std::hash::Hash;
use std::sync::Arc;
-use arrow::datatypes::{DataType, Field, NullableDataType};
+use arrow::datatypes::{DataType, Field};
use ahash::RandomState;
use std::collections::HashSet;
@@ -81,10 +81,7 @@ impl AggregateExpr for DistinctCount {
.map(|data_type| {
Field::new(
&format_state_name(&self.name, "count distinct"),
- DataType::List(Box::new(NullableDataType::new(
- data_type.clone(),
- true,
- ))),
+ DataType::List(Box::new(Field::new("item", data_type.clone(), true))),
false,
)
})
diff --git a/rust/datafusion/src/physical_plan/functions.rs b/rust/datafusion/src/physical_plan/functions.rs
index 41fd210519..b954f479d9 100644
--- a/rust/datafusion/src/physical_plan/functions.rs
+++ b/rust/datafusion/src/physical_plan/functions.rs
@@ -39,12 +39,11 @@ use crate::physical_plan::datetime_expressions;
use crate::physical_plan::expressions::{nullif_func, SUPPORTED_NULLIF_TYPES};
use crate::physical_plan::math_expressions;
use crate::physical_plan::string_expressions;
-use arrow::datatypes::NullableDataType;
use arrow::{
array::ArrayRef,
compute::kernels::length::length,
datatypes::TimeUnit,
- datatypes::{DataType, Schema},
+ datatypes::{DataType, Field, Schema},
record_batch::RecordBatch,
};
use fmt::{Debug, Formatter};
@@ -208,7 +207,7 @@ pub fn return_type(
Ok(DataType::Timestamp(TimeUnit::Nanosecond, None))
}
BuiltinScalarFunction::Array => Ok(DataType::FixedSizeList(
- Box::new(NullableDataType::new(arg_types[0].clone(), true)),
+ Box::new(Field::new("item", arg_types[0].clone(), true)),
arg_types.len() as i32,
)),
BuiltinScalarFunction::NullIf => {
@@ -485,10 +484,7 @@ mod tests {
assert_eq!(
expr.data_type(&schema)?,
// type equals to a common coercion
- DataType::FixedSizeList(
- Box::new(NullableDataType::new(expected_type, true)),
- 2
- )
+ DataType::FixedSizeList(Box::new(Field::new("item", expected_type, true)), 2)
);
// evaluate works
diff --git a/rust/datafusion/src/physical_plan/planner.rs b/rust/datafusion/src/physical_plan/planner.rs
index d6082f3a72..b592111b59 100644
--- a/rust/datafusion/src/physical_plan/planner.rs
+++ b/rust/datafusion/src/physical_plan/planner.rs
@@ -786,7 +786,7 @@ mod tests {
};
let plan = planner.create_physical_plan(&logical_plan, &ctx_state);
- let expected_error = "Extension planner for NoOp created an ExecutionPlan with mismatched schema. LogicalPlan schema: Schema { fields: [Field { name: \"a\", data_type: NullableDataType { data_type: Int32, nullable: false }, dict_id: 0, dict_is_ordered: false }], metadata: {} }, ExecutionPlan schema: Schema { fields: [Field { name: \"b\", data_type: NullableDataType { data_type: Int32, nullable: false }, dict_id: 0, dict_is_ordered: false }], metadata: {} }";
+ let expected_error = "Extension planner for NoOp created an ExecutionPlan with mismatched schema. LogicalPlan schema: Schema { fields: [Field { name: \"a\", data_type: Int32, nullable: false, dict_id: 0, dict_is_ordered: false }], metadata: {} }, ExecutionPlan schema: Schema { fields: [Field { name: \"b\", data_type: Int32, nullable: false, dict_id: 0, dict_is_ordered: false }], metadata: {} }";
match plan {
Ok(_) => assert!(false, "Expected planning failure"),
diff --git a/rust/datafusion/src/scalar.rs b/rust/datafusion/src/scalar.rs
index c64f1a2d02..06309ab84c 100644
--- a/rust/datafusion/src/scalar.rs
+++ b/rust/datafusion/src/scalar.rs
@@ -23,7 +23,10 @@ use arrow::array::{
Int16Builder, Int32Builder, Int64Builder, Int8Builder, ListBuilder, UInt16Builder,
UInt32Builder, UInt64Builder, UInt8Builder,
};
-use arrow::{array::ArrayRef, datatypes::DataType};
+use arrow::{
+ array::ArrayRef,
+ datatypes::{DataType, Field},
+};
use arrow::{
array::{
Array, BooleanArray, Date32Array, Float32Array, Float64Array, Int16Array,
@@ -34,7 +37,6 @@ use arrow::{
};
use crate::error::{DataFusionError, Result};
-use arrow::datatypes::NullableDataType;
/// Represents a dynamically typed, nullable single value.
/// This is the single-valued counter-part of arrow’s `Array`.
@@ -134,7 +136,7 @@ impl ScalarValue {
ScalarValue::Utf8(_) => DataType::Utf8,
ScalarValue::LargeUtf8(_) => DataType::LargeUtf8,
ScalarValue::List(_, data_type) => {
- DataType::List(Box::new(NullableDataType::new(data_type.clone(), true)))
+ DataType::List(Box::new(Field::new("item", data_type.clone(), true)))
}
ScalarValue::Date32(_) => DataType::Date32(DateUnit::Day),
}
diff --git a/rust/datafusion/tests/sql.rs b/rust/datafusion/tests/sql.rs
index bb503a102e..7327487d3b 100644
--- a/rust/datafusion/tests/sql.rs
+++ b/rust/datafusion/tests/sql.rs
@@ -25,7 +25,7 @@ extern crate datafusion;
use arrow::{array::*, datatypes::TimeUnit};
use arrow::{datatypes::Int32Type, datatypes::Int64Type, record_batch::RecordBatch};
use arrow::{
- datatypes::{DataType, Field, NullableDataType, Schema, SchemaRef},
+ datatypes::{DataType, Field, Schema, SchemaRef},
util::display::array_value_to_string,
};
@@ -142,12 +142,12 @@ async fn parquet_list_columns() {
let schema = Arc::new(Schema::new(vec![
Field::new(
"int64_list",
- DataType::List(Box::new(NullableDataType::new(DataType::Int64, true))),
+ DataType::List(Box::new(Field::new("item", DataType::Int64, true))),
true,
),
Field::new(
"utf8_list",
- DataType::List(Box::new(NullableDataType::new(DataType::Utf8, true))),
+ DataType::List(Box::new(Field::new("item", DataType::Utf8, true))),
true,
),
]));