[feature](function) support any type in SQL function (#18392)
Add AnyType to Doris. Support Inference function in fe SQL function.
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.catalog;
|
||||
|
||||
import org.apache.doris.thrift.TColumnType;
|
||||
import org.apache.doris.thrift.TTypeDesc;
|
||||
|
||||
/**
|
||||
* Describes a AnyType type, used for SQL function return type,
|
||||
* NOT used for table column type.
|
||||
*/
|
||||
public class AnyType extends Type {
|
||||
|
||||
@Override
|
||||
protected String toSql(int depth) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String prettyPrint(int lpad) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toThrift(TTypeDesc container) {
|
||||
throw new RuntimeException("can not call toThrift on AnyType.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TColumnType toColumnTypeThrift() {
|
||||
throw new RuntimeException("can not call toColumnTypeThrift on AnyType");
|
||||
}
|
||||
}
|
||||
@ -276,6 +276,15 @@ public class StructType extends Type {
|
||||
return Lists.newArrayList(this);
|
||||
}
|
||||
|
||||
public StructType replaceFieldsWithNames(List<String> names) {
|
||||
Preconditions.checkState(names.size() == fields.size());
|
||||
ArrayList<StructField> newFields = Lists.newArrayList();
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
newFields.add(new StructField(names.get(i), fields.get(i).type));
|
||||
}
|
||||
return new StructType(newFields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof StructType)) {
|
||||
|
||||
@ -117,8 +117,8 @@ public class TemplateType extends Type {
|
||||
expandSizeMap.computeIfAbsent(name, k -> args.length);
|
||||
if (expandSizeMap.get(name) != args.length) {
|
||||
throw new TypeException(
|
||||
String.format("can not expand variadic template type %s to %s size since it's "
|
||||
+ "already expand as %s size", name, args.length, expandSizeMap.get(name)));
|
||||
String.format("can not expand variadic template type %s to %s size since it's "
|
||||
+ "already expand as %s size", name, args.length, expandSizeMap.get(name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -111,6 +111,7 @@ public abstract class Type {
|
||||
new StructField("generic_struct", new ScalarType(PrimitiveType.NULL_TYPE))));
|
||||
public static final StructType STRUCT = new StructType();
|
||||
public static final VariantType VARIANT = new VariantType();
|
||||
public static final AnyType ANY_TYPE = new AnyType();
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(Type.class);
|
||||
private static final ArrayList<ScalarType> integerTypes;
|
||||
|
||||
Reference in New Issue
Block a user