imay commented on a change in pull request #468: Support UDF in syntax
URL: https://github.com/apache/incubator-doris/pull/468#discussion_r244279635
##########
File path: fe/src/main/java/org/apache/doris/catalog/Function.java
##########
@@ -439,4 +500,160 @@ public static String getUdfType(PrimitiveType t) {
return "";
}
}
+
+ public static Function getFunction(List<Function> fns, Function desc,
CompareMode mode) {
+ if (fns == null) {
+ return null;
+ }
+ // First check for identical
+ for (Function f : fns) {
+ if (f.compare(desc, Function.CompareMode.IS_IDENTICAL)) {
+ return f;
+ }
+ }
+ if (mode == Function.CompareMode.IS_IDENTICAL) {
+ return null;
+ }
+
+ // Next check for indistinguishable
+ for (Function f : fns) {
+ if (f.compare(desc, Function.CompareMode.IS_INDISTINGUISHABLE)) {
+ return f;
+ }
+ }
+ if (mode == Function.CompareMode.IS_INDISTINGUISHABLE) {
+ return null;
+ }
+
+ // Next check for strict supertypes
+ for (Function f : fns) {
+ if (f.compare(desc, Function.CompareMode.IS_SUPERTYPE_OF)) {
+ return f;
+ }
+ }
+ if (mode == Function.CompareMode.IS_SUPERTYPE_OF) {
+ return null;
+ }
+ // Finally check for non-strict supertypes
+ for (Function f : fns) {
+ if (f.compare(desc,
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF)) {
+ return f;
+ }
+ }
+ return null;
+ }
+
+ enum FunctionType {
+ ORIGIN(0),
+ SCALAR(1),
+ AGGREGATE(2);
+
+ private int code;
+
+ FunctionType(int code) {
+ this.code = code;
+ }
+ public int getCode() {
+ return code;
+ }
+
+ public static FunctionType fromCode(int code) {
+ switch (code) {
+ case 0:
+ return ORIGIN;
+ case 1:
+ return SCALAR;
+ case 2:
+ return AGGREGATE;
+ }
+ return null;
+ }
+
+ public void write(DataOutput output) throws IOException {
+ output.writeInt(code);
+ }
+ public static FunctionType read(DataInput input) throws IOException {
+ return fromCode(input.readInt());
+ }
+ };
+
+ protected void writeOptionString(DataOutput output, String value) throws
IOException {
Review comment:
OK
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]