Skip to content

Commit 4ddfc72

Browse files
committed
fix: datatype_is_logically_equal for dictionaries
(cherry picked from commit 09c29d7)
1 parent 4e0bc18 commit 4ddfc72

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

datafusion/common/src/dfschema.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,10 @@ impl DFSchema {
700700
(DataType::Dictionary(_, v1), DataType::Dictionary(_, v2)) => {
701701
v1.as_ref() == v2.as_ref()
702702
}
703-
(DataType::Dictionary(_, v1), othertype) => v1.as_ref() == othertype,
704-
(othertype, DataType::Dictionary(_, v1)) => v1.as_ref() == othertype,
703+
(DataType::Dictionary(_, v1), othertype)
704+
| (othertype, DataType::Dictionary(_, v1)) => {
705+
Self::datatype_is_logically_equal(v1.as_ref(), othertype)
706+
}
705707
(DataType::List(f1), DataType::List(f2))
706708
| (DataType::LargeList(f1), DataType::LargeList(f2))
707709
| (DataType::FixedSizeList(f1, _), DataType::FixedSizeList(f2, _)) => {
@@ -1792,6 +1794,12 @@ mod tests {
17921794
&DataType::Utf8,
17931795
&DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Utf8))
17941796
));
1797+
1798+
// Dictionary is logically equal to logically equivalent value type
1799+
assert!(DFSchema::datatype_is_logically_equal(
1800+
&DataType::Utf8View,
1801+
&DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Utf8))
1802+
));
17951803
}
17961804

17971805
#[test]

0 commit comments

Comments
 (0)