From 304781d8379f0e8e6ca079b946ed6180ba23ed28 Mon Sep 17 00:00:00 2001 From: Yulei-Yang Date: Thu, 29 Dec 2022 11:40:14 +0800 Subject: [PATCH] [Improvement](meta) update show create function result (#15414) currently, show create function is designed for native function, it has some non suitable points. this pr bring several improvements, and make result of show create function can be used to create function. 1. add type property. 2. add ALWAYS_NULLABLE perperty for java_udf 3. use file property rather than object_file for java_udf, follow usage of create java_udf 4. remove md5 property, coz file may vary when create function again. 5. remove INIT_FN,UPDATE_FN,MERGE_FN,SERIALIZE_FN etc properties for java_udf, cos java_udf does not need these properties. --- .../doris/catalog/AggregateFunction.java | 35 ++++++++++++------- .../apache/doris/catalog/ScalarFunction.java | 14 ++++++-- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java index 0729b0aa03..07996451d3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java @@ -559,23 +559,32 @@ public class AggregateFunction extends Function { sb.append(" INTERMEDIATE " + getIntermediateType()); } - sb.append(" PROPERTIES (") - .append("\n \"INIT_FN\"=\"" + getInitFnSymbol() + "\"") - .append(",\n \"UPDATE_FN\"=\"" + getUpdateFnSymbol() + "\"") - .append(",\n \"MERGE_FN\"=\"" + getMergeFnSymbol() + "\""); - if (getSerializeFnSymbol() != null) { - sb.append(",\n \"SERIALIZE_FN\"=\"" + getSerializeFnSymbol() + "\""); - } - if (getFinalizeFnSymbol() != null) { - sb.append(",\n \"FINALIZE_FN\"=\"" + getFinalizeFnSymbol() + "\""); + sb.append(" PROPERTIES ("); + if (getBinaryType() != TFunctionBinaryType.JAVA_UDF) { + sb.append("\n \"INIT_FN\"=\"" + getInitFnSymbol() + "\",") + .append("\n \"UPDATE_FN\"=\"" + getUpdateFnSymbol() + "\",") + .append("\n \"MERGE_FN\"=\"" + getMergeFnSymbol() + "\","); + if (getSerializeFnSymbol() != null) { + sb.append("\n \"SERIALIZE_FN\"=\"" + getSerializeFnSymbol() + "\","); + } + if (getFinalizeFnSymbol() != null) { + sb.append("\n \"FINALIZE_FN\"=\"" + getFinalizeFnSymbol() + "\","); + } } if (getSymbolName() != null) { - sb.append(",\n \"SYMBOL\"=\"" + getSymbolName() + "\""); + sb.append("\n \"SYMBOL\"=\"" + getSymbolName() + "\","); } - sb.append(",\n \"OBJECT_FILE\"=") - .append("\"" + (getLocation() == null ? "" : getLocation().toString()) + "\""); - sb.append(",\n \"MD5\"=").append("\"" + getChecksum() + "\""); + if (getBinaryType() == TFunctionBinaryType.JAVA_UDF) { + sb.append("\n \"FILE\"=") + .append("\"" + (getLocation() == null ? "" : getLocation().toString()) + "\","); + boolean isReturnNull = this.getNullableMode() == NullableMode.ALWAYS_NULLABLE; + sb.append("\n \"ALWAYS_NULLABLE\"=").append("\"" + isReturnNull + "\","); + } else { + sb.append("\n \"OBJECT_FILE\"=") + .append("\"" + (getLocation() == null ? "" : getLocation().toString()) + "\","); + } + sb.append("\n \"TYPE\"=").append("\"" + this.getBinaryType() + "\""); sb.append("\n);"); return sb.toString(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ScalarFunction.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ScalarFunction.java index 148faa8ecd..c8e89cae1a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ScalarFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ScalarFunction.java @@ -389,9 +389,17 @@ public class ScalarFunction extends Function { if (getCloseFnSymbol() != null) { sb.append(",\n \"CLOSE_FN\"=").append("\"" + getCloseFnSymbol() + "\""); } - sb.append(",\n \"OBJECT_FILE\"=") - .append("\"" + (getLocation() == null ? "" : getLocation().toString()) + "\""); - sb.append(",\n \"MD5\"=").append("\"" + getChecksum() + "\""); + + if (getBinaryType() == TFunctionBinaryType.JAVA_UDF) { + sb.append(",\n \"FILE\"=") + .append("\"" + (getLocation() == null ? "" : getLocation().toString()) + "\""); + boolean isReturnNull = this.getNullableMode() == NullableMode.ALWAYS_NULLABLE; + sb.append(",\n \"ALWAYS_NULLABLE\"=").append("\"" + isReturnNull + "\""); + } else { + sb.append(",\n \"OBJECT_FILE\"=") + .append("\"" + (getLocation() == null ? "" : getLocation().toString()) + "\""); + } + sb.append(",\n \"TYPE\"=").append("\"" + this.getBinaryType() + "\""); sb.append("\n);"); return sb.toString(); }