This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b654e042d3 [chore](function) let implicit castable signature be pure 
nereids (#57641)
0b654e042d3 is described below

commit 0b654e042d318a376cc4a30f1488eccb93c8c663
Author: morrySnow <[email protected]>
AuthorDate: Fri Nov 7 12:03:11 2025 +0800

    [chore](function) let implicit castable signature be pure nereids (#57641)
    
    ImplicitCastableSignature do not rely on Type#isImplicitlyCastable anymore
---
 .../functions/ImplicitlyCastableSignature.java       | 20 ++++++++++++++------
 .../expressions/functions/scalar/WidthBucket.java    | 10 +++++-----
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java
index 5ce2290bafa..8536a8cf1f6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ImplicitlyCastableSignature.java
@@ -18,16 +18,16 @@
 package org.apache.doris.nereids.trees.expressions.functions;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
 import org.apache.doris.nereids.types.ArrayType;
 import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.NullType;
 import org.apache.doris.nereids.types.coercion.AnyDataType;
 import org.apache.doris.nereids.types.coercion.ComplexDataType;
 import org.apache.doris.nereids.types.coercion.FollowToAnyDataType;
-import org.apache.doris.qe.SessionVariable;
+import org.apache.doris.nereids.util.TypeCoercionUtils;
 
 import java.util.List;
+import java.util.Optional;
 
 /**
  * Implicitly castable function signature. This class equals to 
'CompareMode.IS_SUPERTYPE_OF'.
@@ -56,17 +56,25 @@ public interface ImplicitlyCastableSignature extends 
ComputeSignature {
             return false;
         }
         try {
-            // TODO: copy isImplicitlyCastable method to DataType
-            // TODO: resolve AnyDataType invoke toCatalogDataType
             if (signatureType instanceof ArrayType) {
                 if (((ArrayType) signatureType).getItemType() instanceof 
AnyDataType) {
                     return false;
                 }
             }
-            if (Type.isImplicitlyCastable(realType.toCatalogDataType(), 
signatureType.toCatalogDataType(), true,
-                    SessionVariable.getEnableDecimal256())) {
+            if (realType.isStringLikeType() && signatureType.isStringLikeType()
+                    || realType.equals(signatureType)) {
                 return true;
             }
+            if ((realType.isNumericType() || realType.isBooleanType()) && 
signatureType.isNumericType()
+                    || (realType.isDateLikeType() || realType.isTimeType())
+                    && (signatureType.isDateLikeType() || 
signatureType.isTimeType())) {
+                Optional<DataType> commonType = 
TypeCoercionUtils.findWiderTypeForTwo(
+                        realType, signatureType, true, true);
+                if (commonType.isPresent() && 
commonType.get().toCatalogDataType()
+                        .matchesType(signatureType.toCatalogDataType())) {
+                    return true;
+                }
+            }
         } catch (Throwable t) {
             // the signatureType maybe DataType and can not cast to catalog 
data type.
         }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WidthBucket.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WidthBucket.java
index 79823102dc0..2404d471d9f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WidthBucket.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WidthBucket.java
@@ -39,6 +39,10 @@ import java.util.List;
  */
 public class WidthBucket extends ScalarFunction implements 
ExplicitlyCastableSignature, PropagateNullable {
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE,
+                    DoubleType.INSTANCE, DoubleType.INSTANCE, 
TinyIntType.INSTANCE),
+            FunctionSignature.ret(BigIntType.INSTANCE).args(FloatType.INSTANCE,
+                    FloatType.INSTANCE, FloatType.INSTANCE, 
TinyIntType.INSTANCE),
             
FunctionSignature.ret(BigIntType.INSTANCE).args(TinyIntType.INSTANCE,
                     TinyIntType.INSTANCE, TinyIntType.INSTANCE, 
TinyIntType.INSTANCE),
             
FunctionSignature.ret(BigIntType.INSTANCE).args(SmallIntType.INSTANCE,
@@ -46,11 +50,7 @@ public class WidthBucket extends ScalarFunction implements 
ExplicitlyCastableSig
             
FunctionSignature.ret(BigIntType.INSTANCE).args(IntegerType.INSTANCE,
                     IntegerType.INSTANCE, IntegerType.INSTANCE, 
IntegerType.INSTANCE),
             
FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE,
-                    BigIntType.INSTANCE, BigIntType.INSTANCE, 
BigIntType.INSTANCE),
-            FunctionSignature.ret(BigIntType.INSTANCE).args(FloatType.INSTANCE,
-                    FloatType.INSTANCE, FloatType.INSTANCE, 
TinyIntType.INSTANCE),
-            
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE,
-                    DoubleType.INSTANCE, DoubleType.INSTANCE, 
TinyIntType.INSTANCE)
+                    BigIntType.INSTANCE, BigIntType.INSTANCE, 
BigIntType.INSTANCE)
             );
 
     /**


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to