Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ impl DFSchema {
}

/// Returns true of two [`DataType`]s are semantically equal (same
/// name and type), ignoring both metadata and nullability, and decimal precision/scale.
/// name and type), ignoring both metadata and nullability, decimal precision/scale,
/// and timezone time units/timezones.
///
/// request to upstream: <https://github.com/apache/arrow-rs/issues/3199>
pub fn datatype_is_semantically_equal(dt1: &DataType, dt2: &DataType) -> bool {
Expand Down Expand Up @@ -806,6 +807,10 @@ impl DFSchema {
DataType::Decimal256(_l_precision, _l_scale),
DataType::Decimal256(_r_precision, _r_scale),
) => true,
(
DataType::Timestamp(_l_time_unit, _l_timezone),
DataType::Timestamp(_r_time_unit, _r_timezone),
) => true,
_ => dt1 == dt2,
}
}
Expand Down Expand Up @@ -1596,6 +1601,14 @@ mod tests {
&DataType::Int16
));

// Any two timestamp types should match
assert!(DFSchema::datatype_is_semantically_equal(
&DataType::Timestamp(
arrow::datatypes::TimeUnit::Microsecond,
Some("UTC".into())
),
&DataType::Timestamp(arrow::datatypes::TimeUnit::Millisecond, None),
));
// Test lists

// Succeeds if both have the same element type, disregards names and nullability
Expand Down
Loading