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 99063ca33c chore: Reuse DFSSchema::datatype_is_logically_equal method
(#10867)
99063ca33c is described below
commit 99063ca33cda583a0a97767c93708fb1d6e717a1
Author: advancedxy <[email protected]>
AuthorDate: Wed Jun 12 00:43:22 2024 +0900
chore: Reuse DFSSchema::datatype_is_logically_equal method (#10867)
---
datafusion/common/src/dfschema.rs | 2 +-
datafusion/physical-expr/src/expressions/in_list.rs | 18 ++++--------------
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/datafusion/common/src/dfschema.rs
b/datafusion/common/src/dfschema.rs
index 3686af90db..0dab13d087 100644
--- a/datafusion/common/src/dfschema.rs
+++ b/datafusion/common/src/dfschema.rs
@@ -666,7 +666,7 @@ impl DFSchema {
/// than datatype_is_semantically_equal in that a Dictionary<K,V> type is
logically
/// equal to a plain V type, but not semantically equal. Dictionary<K1,
V1> is also
/// logically equal to Dictionary<K2, V1>.
- fn datatype_is_logically_equal(dt1: &DataType, dt2: &DataType) -> bool {
+ pub fn datatype_is_logically_equal(dt1: &DataType, dt2: &DataType) -> bool
{
// check nested fields
match (dt1, dt2) {
(DataType::Dictionary(_, v1), DataType::Dictionary(_, v2)) => {
diff --git a/datafusion/physical-expr/src/expressions/in_list.rs
b/datafusion/physical-expr/src/expressions/in_list.rs
index a36ec9c8eb..53c790ff6b 100644
--- a/datafusion/physical-expr/src/expressions/in_list.rs
+++ b/datafusion/physical-expr/src/expressions/in_list.rs
@@ -38,7 +38,9 @@ use datafusion_common::cast::{
as_boolean_array, as_generic_binary_array, as_string_array,
};
use datafusion_common::hash_utils::HashValue;
-use datafusion_common::{exec_err, internal_err, not_impl_err, Result,
ScalarValue};
+use datafusion_common::{
+ exec_err, internal_err, not_impl_err, DFSchema, Result, ScalarValue,
+};
use datafusion_expr::ColumnarValue;
use ahash::RandomState;
@@ -416,18 +418,6 @@ impl PartialEq<dyn Any> for InListExpr {
}
}
-/// Checks if two types are logically equal, dictionary types are compared by
their value types.
-fn is_logically_eq(lhs: &DataType, rhs: &DataType) -> bool {
- match (lhs, rhs) {
- (DataType::Dictionary(_, v1), DataType::Dictionary(_, v2)) => {
- v1.as_ref().eq(v2.as_ref())
- }
- (DataType::Dictionary(_, l), _) => l.as_ref().eq(rhs),
- (_, DataType::Dictionary(_, r)) => lhs.eq(r.as_ref()),
- _ => lhs.eq(rhs),
- }
-}
-
/// Creates a unary expression InList
pub fn in_list(
expr: Arc<dyn PhysicalExpr>,
@@ -439,7 +429,7 @@ pub fn in_list(
let expr_data_type = expr.data_type(schema)?;
for list_expr in list.iter() {
let list_expr_data_type = list_expr.data_type(schema)?;
- if !is_logically_eq(&expr_data_type, &list_expr_data_type) {
+ if !DFSchema::datatype_is_logically_equal(&expr_data_type,
&list_expr_data_type) {
return internal_err!(
"The data type inlist should be same, the value type is
{expr_data_type}, one of list expr type is {list_expr_data_type}"
);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]