This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new c68ba72a0b6 branch-4.0: [chore](function) let implicit castable
signature be pure nereids #57641 (#57800)
c68ba72a0b6 is described below
commit c68ba72a0b6f185920d0323d619c163973af772d
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Nov 11 10:52:50 2025 +0800
branch-4.0: [chore](function) let implicit castable signature be pure
nereids #57641 (#57800)
Cherry-picked from #57641
Co-authored-by: morrySnow <[email protected]>
---
.../functions/ExplicitlyCastableSignature.java | 4 ++--
.../functions/ImplicitlyCastableSignature.java | 20 ++++++++++++++------
.../expressions/functions/scalar/WidthBucket.java | 10 +++++-----
.../apache/doris/nereids/util/TypeCoercionUtils.java | 2 +-
4 files changed, 22 insertions(+), 14 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java
index 8e3491259a5..38d9b665173 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ExplicitlyCastableSignature.java
@@ -18,12 +18,12 @@
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.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.nereids.util.TypeCoercionUtils;
import java.util.List;
@@ -55,7 +55,7 @@ public interface ExplicitlyCastableSignature extends
ComputeSignature {
}
try {
// TODO: copy canCastTo method to DataType
- return Type.canCastTo(realType.toCatalogDataType(),
signatureType.toCatalogDataType());
+ return TypeCoercionUtils.canCastTo(realType, signatureType);
} catch (Throwable t) {
// the signatureType maybe DataType and can not cast to catalog
data type.
return false;
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)
);
/**
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java
index 233732233d9..6f75fab9993 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java
@@ -487,7 +487,7 @@ public class TypeCoercionUtils {
}
}
- private static boolean canCastTo(DataType input, DataType target) {
+ public static boolean canCastTo(DataType input, DataType target) {
return CheckCast.checkWithLooseAggState(input, target,
SessionVariable.enableStrictCast());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]