From 09c29d755964c1e7235a43a3d3aefbae2852b855 Mon Sep 17 00:00:00 2001 From: Anna-Rose Lescure Date: Wed, 4 Feb 2026 16:26:50 +0100 Subject: [PATCH 1/2] fix: datatype_is_logically_equal for dictionaries --- datafusion/common/src/dfschema.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs index f67e7e4517d2b..de6d87401581b 100644 --- a/datafusion/common/src/dfschema.rs +++ b/datafusion/common/src/dfschema.rs @@ -700,8 +700,10 @@ impl DFSchema { (DataType::Dictionary(_, v1), DataType::Dictionary(_, v2)) => { v1.as_ref() == v2.as_ref() } - (DataType::Dictionary(_, v1), othertype) => v1.as_ref() == othertype, - (othertype, DataType::Dictionary(_, v1)) => v1.as_ref() == othertype, + (DataType::Dictionary(_, v1), othertype) + | (othertype, DataType::Dictionary(_, v1)) => { + Self::datatype_is_logically_equal(v1.as_ref(), othertype) + } (DataType::List(f1), DataType::List(f2)) | (DataType::LargeList(f1), DataType::LargeList(f2)) | (DataType::FixedSizeList(f1, _), DataType::FixedSizeList(f2, _)) => { @@ -1798,6 +1800,12 @@ mod tests { &DataType::Utf8, &DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Utf8)) )); + + // Dictionary is logically equal to logically equivalent value type + assert!(DFSchema::datatype_is_logically_equal( + &DataType::Utf8View, + &DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Utf8)) + )); } #[test] From 5bab65b24e08f26ba70751daa71112176bf59840 Mon Sep 17 00:00:00 2001 From: Anna-Rose Lescure Date: Thu, 5 Feb 2026 11:57:48 +0100 Subject: [PATCH 2/2] fix: datatype_is_logically_equal for (Dict, Dict) --- datafusion/common/src/dfschema.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs index de6d87401581b..0a05622e30c8b 100644 --- a/datafusion/common/src/dfschema.rs +++ b/datafusion/common/src/dfschema.rs @@ -698,7 +698,7 @@ impl DFSchema { // check nested fields match (dt1, dt2) { (DataType::Dictionary(_, v1), DataType::Dictionary(_, v2)) => { - v1.as_ref() == v2.as_ref() + Self::datatype_is_logically_equal(v1.as_ref(), v2.as_ref()) } (DataType::Dictionary(_, v1), othertype) | (othertype, DataType::Dictionary(_, v1)) => { @@ -1806,6 +1806,21 @@ mod tests { &DataType::Utf8View, &DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Utf8)) )); + + assert!(DFSchema::datatype_is_logically_equal( + &DataType::Dictionary( + Box::new(DataType::Int32), + Box::new(DataType::List( + Field::new("element", DataType::Utf8, false).into() + )) + ), + &DataType::Dictionary( + Box::new(DataType::Int32), + Box::new(DataType::List( + Field::new("element", DataType::Utf8View, false).into() + )) + ) + )); } #[test]