Class OperatorConversions
java.lang.Object
org.apache.druid.sql.calcite.expression.OperatorConversions
Utilities for assisting in writing
SqlOperatorConversion implementations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classOperatorConversions.OperatorBuilder<T extends org.apache.calcite.sql.SqlFunction>Helps in creating the operator builder along with validations and type inference for simple operator conversions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OperatorConversions.OperatorBuilder<org.apache.calcite.sql.SqlAggFunction>aggregatorBuilder(String name) Returns a builder that helpsSqlAggregatorimplementations create theSqlAggFunctionobjects they need to return fromSqlAggregator.calciteFunction().static DruidExpressionconvertCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName) Deprecated.static DruidExpressionconvertCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName, Function<List<DruidExpression>, SimpleExtraction> simpleExtractionFunction) Deprecated.static DruidExpressionconvertCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, DruidExpression.DruidExpressionCreator expressionFunction) static DruidExpressionconvertCallBuilder(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, DruidExpression.ExpressionGenerator expressionGenerator) static DruidExpressionconvertCallWithPostAggOperands(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, DruidExpression.DruidExpressionCreator expressionFunction, PostAggregatorVisitor postAggregatorVisitor) static DruidExpressionconvertDirectCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName) static DruidExpressionconvertDirectCallWithExtraction(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName, Function<List<DruidExpression>, SimpleExtraction> simpleExtractionFunction) static DirectOperatorConversiondruidBinaryLongFn(String sqlOperator, String druidFunctionName) static DirectOperatorConversiondruidUnaryDoubleFn(String sqlOperator, String druidFunctionName) static DirectOperatorConversiondruidUnaryLongFn(String sqlOperator, String druidFunctionName) static <T> TgetOperandWithDefault(List<org.apache.calcite.rex.RexNode> operands, int i, Function<org.apache.calcite.rex.RexNode, T> f, T defaultReturnValue) Gets operand "i" from "operands", or returns a default value if it doesn't exist (operands is too short) or is null.static OperatorConversions.OperatorBuilder<org.apache.calcite.sql.SqlFunction>operatorBuilder(String name) Returns a builder that helpsSqlOperatorConversionimplementations create theSqlFunctionobjects they need to return fromSqlOperatorConversion.calciteOperator().static booleanthrowOrReturn(boolean throwOnFailure, org.apache.calcite.sql.SqlCallBinding callBinding, Function<org.apache.calcite.sql.SqlCallBinding, org.apache.calcite.runtime.CalciteException> exceptionMapper) static PostAggregatortoPostAggregator(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, PostAggregatorVisitor postAggregatorVisitor, boolean useExpressions) Translate a CalciteRexNodeto a Druid PostAggregator
-
Constructor Details
-
OperatorConversions
public OperatorConversions()
-
-
Method Details
-
convertDirectCall
@Nullable public static DruidExpression convertDirectCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName) -
convertDirectCallWithExtraction
@Nullable public static DruidExpression convertDirectCallWithExtraction(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName, Function<List<DruidExpression>, SimpleExtraction> simpleExtractionFunction) -
convertCallBuilder
@Nullable public static DruidExpression convertCallBuilder(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, DruidExpression.ExpressionGenerator expressionGenerator) -
convertCall
@Nullable public static DruidExpression convertCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, DruidExpression.DruidExpressionCreator expressionFunction) -
convertCall
@Deprecated @Nullable public static DruidExpression convertCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName) Deprecated. -
convertCall
@Deprecated @Nullable public static DruidExpression convertCall(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, String functionName, Function<List<DruidExpression>, SimpleExtraction> simpleExtractionFunction) Deprecated. -
getOperandWithDefault
public static <T> T getOperandWithDefault(List<org.apache.calcite.rex.RexNode> operands, int i, Function<org.apache.calcite.rex.RexNode, T> f, T defaultReturnValue) Gets operand "i" from "operands", or returns a default value if it doesn't exist (operands is too short) or is null. -
convertCallWithPostAggOperands
@Nullable public static DruidExpression convertCallWithPostAggOperands(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, DruidExpression.DruidExpressionCreator expressionFunction, PostAggregatorVisitor postAggregatorVisitor) -
toPostAggregator
@Nullable public static PostAggregator toPostAggregator(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode, PostAggregatorVisitor postAggregatorVisitor, boolean useExpressions) Translate a CalciteRexNodeto a Druid PostAggregator- Parameters:
plannerContext- SQL planner contextrowSignature- signature of the rows to be extracted fromrexNode- expression meant to be applied on top of the rowspostAggregatorVisitor- visitor that manages postagg names and tracks postaggs that were created by the translationuseExpressions- whether we should considerExpressionPostAggregatoras a target- Returns:
- rexNode referring to fields in rowOrder, or null if not possible
-
operatorBuilder
public static OperatorConversions.OperatorBuilder<org.apache.calcite.sql.SqlFunction> operatorBuilder(String name) Returns a builder that helpsSqlOperatorConversionimplementations create theSqlFunctionobjects they need to return fromSqlOperatorConversion.calciteOperator(). -
aggregatorBuilder
public static OperatorConversions.OperatorBuilder<org.apache.calcite.sql.SqlAggFunction> aggregatorBuilder(String name) Returns a builder that helpsSqlAggregatorimplementations create theSqlAggFunctionobjects they need to return fromSqlAggregator.calciteFunction(). -
throwOrReturn
public static boolean throwOrReturn(boolean throwOnFailure, org.apache.calcite.sql.SqlCallBinding callBinding, Function<org.apache.calcite.sql.SqlCallBinding, org.apache.calcite.runtime.CalciteException> exceptionMapper) -
druidUnaryLongFn
public static DirectOperatorConversion druidUnaryLongFn(String sqlOperator, String druidFunctionName) -
druidBinaryLongFn
public static DirectOperatorConversion druidBinaryLongFn(String sqlOperator, String druidFunctionName) -
druidUnaryDoubleFn
public static DirectOperatorConversion druidUnaryDoubleFn(String sqlOperator, String druidFunctionName)
-