From 0b3f16af83c03fdcf5df4915f78058e40176a12b Mon Sep 17 00:00:00 2001 From: morrySnow Date: Tue, 7 Mar 2023 20:54:51 +0800 Subject: [PATCH] [fix](planner) insert default value should not change return type of function object in function set --- .../doris/analysis/FunctionCallExpr.java | 3 ++- .../org/apache/doris/catalog/Function.java | 20 +++++++++++++++++++ .../test_current_timestamp.groovy | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index 9e101275a046c5..89130f5d8433e2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -1072,7 +1072,8 @@ protected String getFunctionNotFoundError(Type[] argTypes) { * @throws AnalysisException */ public void analyzeImplForDefaultValue(Type type) throws AnalysisException { - fn = getBuiltinFunction(fnName.getFunction(), new Type[0], Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF); + fn = new Function(getBuiltinFunction(fnName.getFunction(), new Type[0], + Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF)); fn.setReturnType(type); this.type = type; for (int i = 0; i < children.size(); ++i) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java index f1a608a9b83f92..6dc5319d9358a8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java @@ -163,6 +163,26 @@ public Function(long id, FunctionName name, List argTypes, Type retType, this(id, name, argTypes, retType, hasVarArgs, TFunctionBinaryType.BUILTIN, true, vectorized, mode); } + public Function(Function other) { + if (other == null) { + return; + } + this.id = other.id; + this.name = new FunctionName(other.name.getDb(), other.name.getFunction()); + this.hasVarArgs = other.hasVarArgs; + this.retType = other.retType; + this.userVisible = other.userVisible; + this.nullableMode = other.nullableMode; + this.vectorized = other.vectorized; + this.binaryType = other.binaryType; + this.location = other.location; + if (other.argTypes != null) { + this.argTypes = new Type[other.argTypes.length]; + System.arraycopy(other.argTypes, 0, this.argTypes, 0, other.argTypes.length); + } + this.checksum = other.checksum; + } + public FunctionName getFunctionName() { return name; } diff --git a/regression-test/suites/correctness_p0/test_current_timestamp.groovy b/regression-test/suites/correctness_p0/test_current_timestamp.groovy index e0cdecbcfc1bd2..53ac6d6838015f 100644 --- a/regression-test/suites/correctness_p0/test_current_timestamp.groovy +++ b/regression-test/suites/correctness_p0/test_current_timestamp.groovy @@ -49,6 +49,8 @@ suite("test_current_timestamp") { qt_insert_into """ select count(*) from ${tableName} where to_date(dt_4) = to_date(dt_5); """ qt_insert_into """ select count(*) from ${tableName} where to_date(dt_6) = to_date(dt_7); """ + sql """select now()""" + // test stream load. streamLoad { table "${tableName}" @@ -64,4 +66,6 @@ suite("test_current_timestamp") { qt_stream_load """ select count(*) from ${tableName} where id > 4 and to_date(dt_2) = to_date(dt_3); """ qt_stream_load """ select count(*) from ${tableName} where id > 4 and to_date(dt_4) = to_date(dt_5); """ qt_stream_load """ select count(*) from ${tableName} where id > 4 and to_date(dt_6) = to_date(dt_7); """ + + sql """select now()""" }