This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 86db4bf3c5 ignore metadata when compare with nested type (#15366)
86db4bf3c5 is described below
commit 86db4bf3c5af9704377afa1ecc596ce7d9167f7f
Author: Jax Liu <[email protected]>
AuthorDate: Fri Mar 28 03:42:38 2025 +0800
ignore metadata when compare with nested type (#15366)
---
datafusion/expr-common/src/type_coercion/binary.rs | 2 +-
datafusion/optimizer/src/analyzer/type_coercion.rs | 27 +++++++++++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/datafusion/expr-common/src/type_coercion/binary.rs
b/datafusion/expr-common/src/type_coercion/binary.rs
index c874067af3..c49de39840 100644
--- a/datafusion/expr-common/src/type_coercion/binary.rs
+++ b/datafusion/expr-common/src/type_coercion/binary.rs
@@ -719,7 +719,7 @@ pub fn try_type_union_resolution_with_struct(
/// strings. For example when comparing `'2' > 1`, the arguments will be
/// coerced to `Utf8` for comparison
pub fn comparison_coercion(lhs_type: &DataType, rhs_type: &DataType) ->
Option<DataType> {
- if lhs_type == rhs_type {
+ if lhs_type.equals_datatype(rhs_type) {
// same type => equality is possible
return Some(lhs_type.clone());
}
diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs
b/datafusion/optimizer/src/analyzer/type_coercion.rs
index a77249424f..d47f7ea6ce 100644
--- a/datafusion/optimizer/src/analyzer/type_coercion.rs
+++ b/datafusion/optimizer/src/analyzer/type_coercion.rs
@@ -1054,7 +1054,7 @@ mod test {
use std::sync::Arc;
use arrow::datatypes::DataType::Utf8;
- use arrow::datatypes::{DataType, Field, Schema, TimeUnit};
+ use arrow::datatypes::{DataType, Field, Schema, SchemaBuilder, TimeUnit};
use crate::analyzer::type_coercion::{
coerce_case_expression, TypeCoercion, TypeCoercionRewriter,
@@ -2091,6 +2091,31 @@ mod test {
Ok(())
}
+ #[test]
+ fn test_map_with_diff_name() -> Result<()> {
+ let mut builder = SchemaBuilder::new();
+ builder.push(Field::new("key", Utf8, false));
+ builder.push(Field::new("value", DataType::Float64, true));
+ let struct_fields = builder.finish().fields;
+
+ let fields =
+ Field::new("entries", DataType::Struct(struct_fields.clone()),
false);
+ let map_type_entries = DataType::Map(Arc::new(fields), false);
+
+ let fields = Field::new("key_value", DataType::Struct(struct_fields),
false);
+ let may_type_cutsom = DataType::Map(Arc::new(fields), false);
+
+ let expr = col("a").eq(cast(col("a"), may_type_cutsom));
+ let empty = empty_with_type(map_type_entries);
+ let plan = LogicalPlan::Projection(Projection::try_new(vec![expr],
empty)?);
+ let expected = "Projection: a = CAST(CAST(a AS Map(Field { name:
\"key_value\", data_type: Struct([Field { name: \"key\", data_type: Utf8, \
+ nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} },
Field { name: \"value\", data_type: Float64, nullable: true, dict_id: 0,
dict_is_ordered: false, metadata: {} }]), \
+ nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} },
false)) AS Map(Field { name: \"entries\", data_type: Struct([Field { name:
\"key\", data_type: Utf8, nullable: false, \
+ dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name:
\"value\", data_type: Float64, nullable: true, dict_id: 0, dict_is_ordered:
false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false,
metadata: {} }, false))\n \
+ EmptyRelation";
+ assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)
+ }
+
#[test]
fn interval_plus_timestamp() -> Result<()> {
// SELECT INTERVAL '1' YEAR + '2000-01-01T00:00:00'::timestamp;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]