jayzhan211 commented on code in PR #14268:
URL: https://github.com/apache/datafusion/pull/14268#discussion_r1944643137


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -584,23 +541,36 @@ fn get_valid_types(
                 match target_type_class {
                     TypeSignatureClass::Native(native_type) => {
                         let target_type = native_type.native();
-                        if &logical_type == target_type {
-                            return target_type.default_cast_for(current_type);
+                        if &logical_type == target_type
+                            || logical_type == NativeType::Null
+                            || (target_type.is_numeric() && 
logical_type.is_numeric())
+                        {
+                            target_type.default_cast_for(current_type)
+                        } else {
+                            internal_err!(
+                                "Expect {target_type_class} but received 
{current_type}"
+                            )
                         }
-
-                        if logical_type == NativeType::Null {
-                            return target_type.default_cast_for(current_type);
+                    }
+                    TypeSignatureClass::Numeric(native_type) => {
+                        let target_type = native_type.native();
+                        if target_type.is_numeric() && 
logical_type.is_numeric() {
+                            target_type.default_cast_for(current_type)
+                        } else {
+                            internal_err!(
+                                "Expect {target_type_class} but received 
{current_type}"
+                            )
                         }
-
+                    }
+                    TypeSignatureClass::Integer(native_type) => {
+                        let target_type = native_type.native();

Review Comment:
   `Ok(current_type.to_owned())`



##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -584,23 +541,36 @@ fn get_valid_types(
                 match target_type_class {
                     TypeSignatureClass::Native(native_type) => {
                         let target_type = native_type.native();
-                        if &logical_type == target_type {
-                            return target_type.default_cast_for(current_type);
+                        if &logical_type == target_type
+                            || logical_type == NativeType::Null
+                            || (target_type.is_numeric() && 
logical_type.is_numeric())
+                        {
+                            target_type.default_cast_for(current_type)
+                        } else {
+                            internal_err!(
+                                "Expect {target_type_class} but received 
{current_type}"
+                            )
                         }
-
-                        if logical_type == NativeType::Null {
-                            return target_type.default_cast_for(current_type);
+                    }
+                    TypeSignatureClass::Numeric(native_type) => {
+                        let target_type = native_type.native();
+                        if target_type.is_numeric() && 
logical_type.is_numeric() {
+                            target_type.default_cast_for(current_type)
+                        } else {
+                            internal_err!(
+                                "Expect {target_type_class} but received 
{current_type}"
+                            )
                         }
-
+                    }
+                    TypeSignatureClass::Integer(native_type) => {
+                        let target_type = native_type.native();

Review Comment:
   `Ok(current_type.to_owned())`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to