Class OperatorConversions.OperatorBuilder<T extends org.apache.calcite.sql.SqlFunction>
java.lang.Object
org.apache.druid.sql.calcite.expression.OperatorConversions.OperatorBuilder<T>
- Direct Known Subclasses:
OperatorConversions.AggregatorBuilder
- Enclosing class:
- OperatorConversions
public static class OperatorConversions.OperatorBuilder<T extends org.apache.calcite.sql.SqlFunction>
extends Object
Helps in creating the operator builder along with validations and type inference for simple operator conversions.
The type checker for this operator conversion can be either supplied manually, or an instance of
DefaultOperandTypeChecker will be used if the user passes in operandTypes and other optional
parameters. Exactly one of them must be supplied to the builder.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.calcite.sql.SqlFunctionCategoryprotected org.apache.calcite.sql.SqlKindprotected final Stringprotected org.apache.calcite.sql.type.SqlReturnTypeInference -
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates aSqlFunctionfrom this builder.protected org.apache.calcite.sql.type.SqlOperandTypeCheckerprotected org.apache.calcite.sql.type.SqlOperandTypeInferencefunctionCategory(org.apache.calcite.sql.SqlFunctionCategory functionCategory) Sets theSqlKindof the operator.literalOperands(int... literalOperands) Equivalent to callingDefaultOperandTypeChecker.Builder.literalOperands(int...); leads to using aDefaultOperandTypeCheckeras our operand type checker.operandNames(String... operandNames) Signifies that a function accepts operands with the provided names.operandTypeChecker(org.apache.calcite.sql.type.SqlOperandTypeChecker operandTypeChecker) Provide customized operand type checking logic.operandTypeInference(org.apache.calcite.sql.type.SqlOperandTypeInference operandTypeInference) operandTypes(org.apache.calcite.sql.type.SqlTypeFamily... operandTypes) Equivalent to callingDefaultOperandTypeChecker.Builder.operandTypes(SqlTypeFamily...); leads to using aDefaultOperandTypeCheckeras our operand type checker.requiredOperandCount(int requiredOperandCount) Equivalent to callingDefaultOperandTypeChecker.Builder.requiredOperandCount(Integer); leads to using aDefaultOperandTypeCheckeras our operand type checker.requiredOperands(int requiredOperands) Deprecated.returnTypeArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName elementTypeName) Sets the return type of the operator to an array type with elements of "typeName", marked as nullable.returnTypeCascadeNullable(org.apache.calcite.sql.type.SqlTypeName typeName) Sets the return type of the operator to "typeName", marked as nullable if any of its operands are nullable.returnTypeInference(org.apache.calcite.sql.type.SqlReturnTypeInference returnTypeInference) Provides customized return type inference logic.returnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName typeName) Sets the return type of the operator to "typeName", marked as non-nullable.returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName typeName) Sets the return type of the operator to "typeName", marked as nullable.returnTypeNullableArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName elementTypeName) Sets the return type of the operator to an array type with elements of "typeName", marked as nullable.
-
Field Details
-
name
-
kind
protected org.apache.calcite.sql.SqlKind kind -
returnTypeInference
protected org.apache.calcite.sql.type.SqlReturnTypeInference returnTypeInference -
functionCategory
protected org.apache.calcite.sql.SqlFunctionCategory functionCategory
-
-
Method Details
-
returnTypeNonNull
public OperatorConversions.OperatorBuilder<T> returnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName typeName) Sets the return type of the operator to "typeName", marked as non-nullable. If this method is used it implies the operator should never, ever, return null. One ofreturnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName),returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName),returnTypeCascadeNullable(SqlTypeName)returnTypeNullableArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName), orreturnTypeInference(SqlReturnTypeInference)must be used before callingbuild(). These methods cannot be mixed; you must call exactly one. -
returnTypeNullable
public OperatorConversions.OperatorBuilder<T> returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName typeName) Sets the return type of the operator to "typeName", marked as nullable. One ofreturnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName),returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName),returnTypeCascadeNullable(SqlTypeName)returnTypeNullableArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName), orreturnTypeInference(SqlReturnTypeInference)must be used before callingbuild(). These methods cannot be mixed; you must call exactly one. -
returnTypeCascadeNullable
public OperatorConversions.OperatorBuilder<T> returnTypeCascadeNullable(org.apache.calcite.sql.type.SqlTypeName typeName) Sets the return type of the operator to "typeName", marked as nullable if any of its operands are nullable. One ofreturnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName),returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName),returnTypeCascadeNullable(SqlTypeName)returnTypeNullableArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName), orreturnTypeInference(SqlReturnTypeInference)must be used before callingbuild(). These methods cannot be mixed; you must call exactly one. -
returnTypeArrayWithNullableElements
public OperatorConversions.OperatorBuilder<T> returnTypeArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName elementTypeName) Sets the return type of the operator to an array type with elements of "typeName", marked as nullable. One ofreturnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName),returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName),returnTypeCascadeNullable(SqlTypeName)returnTypeArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName), orreturnTypeInference(SqlReturnTypeInference)must be used before callingbuild(). These methods cannot be mixed; you must call exactly one. -
returnTypeNullableArrayWithNullableElements
public OperatorConversions.OperatorBuilder<T> returnTypeNullableArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName elementTypeName) Sets the return type of the operator to an array type with elements of "typeName", marked as nullable. One ofreturnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName),returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName),returnTypeCascadeNullable(SqlTypeName)returnTypeArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName), orreturnTypeInference(SqlReturnTypeInference)must be used before callingbuild(). These methods cannot be mixed; you must call exactly one. -
returnTypeInference
public OperatorConversions.OperatorBuilder<T> returnTypeInference(org.apache.calcite.sql.type.SqlReturnTypeInference returnTypeInference) Provides customized return type inference logic. One ofreturnTypeNonNull(org.apache.calcite.sql.type.SqlTypeName),returnTypeNullable(org.apache.calcite.sql.type.SqlTypeName),returnTypeCascadeNullable(SqlTypeName)returnTypeNullableArrayWithNullableElements(org.apache.calcite.sql.type.SqlTypeName), orreturnTypeInference(SqlReturnTypeInference)must be used before callingbuild(). These methods cannot be mixed; you must call exactly one. -
functionCategory
public OperatorConversions.OperatorBuilder<T> functionCategory(org.apache.calcite.sql.SqlFunctionCategory functionCategory) Sets theSqlKindof the operator. The default, if not provided, isSqlFunctionCategory.USER_DEFINED_FUNCTION. -
operandTypeChecker
public OperatorConversions.OperatorBuilder<T> operandTypeChecker(org.apache.calcite.sql.type.SqlOperandTypeChecker operandTypeChecker) Provide customized operand type checking logic. EitheroperandTypes(SqlTypeFamily...)or this method must be used before callingbuild(). These methods cannot be mixed; you must call exactly one. -
operandNames
Signifies that a function accepts operands with the provided names. This is used to implementSqlOperandTypeChecker.getAllowedSignatures(SqlOperator, String). If not provided, theoperandTypesare used instead. -
operandTypes
public OperatorConversions.OperatorBuilder<T> operandTypes(org.apache.calcite.sql.type.SqlTypeFamily... operandTypes) Equivalent to callingDefaultOperandTypeChecker.Builder.operandTypes(SqlTypeFamily...); leads to using aDefaultOperandTypeCheckeras our operand type checker. May be used in conjunction withrequiredOperandCount(int)andliteralOperands(int...)in order to further refine operand checking logic. For deeper control, useoperandTypeChecker(SqlOperandTypeChecker)instead. -
requiredOperandCount
Equivalent to callingDefaultOperandTypeChecker.Builder.requiredOperandCount(Integer); leads to using aDefaultOperandTypeCheckeras our operand type checker. -
requiredOperands
Deprecated.Alias forrequiredOperandCount(int). Deprecated because it means "operand count" rather than "specific operands", and therefore the name can cause confusion withliteralOperands(int...). The latter really does mean "specific operands". -
literalOperands
Equivalent to callingDefaultOperandTypeChecker.Builder.literalOperands(int...); leads to using aDefaultOperandTypeCheckeras our operand type checker. Not compatible withoperandTypeChecker(SqlOperandTypeChecker). -
operandTypeInference
public OperatorConversions.OperatorBuilder<T> operandTypeInference(org.apache.calcite.sql.type.SqlOperandTypeInference operandTypeInference) -
build
Creates aSqlFunctionfrom this builder. -
buildOperandTypeChecker
protected org.apache.calcite.sql.type.SqlOperandTypeChecker buildOperandTypeChecker() -
buildOperandTypeInference
protected org.apache.calcite.sql.type.SqlOperandTypeInference buildOperandTypeInference()
-