Class SearchOperatorConversion
java.lang.Object
org.apache.druid.sql.calcite.expression.builtin.SearchOperatorConversion
- All Implemented Interfaces:
SqlOperatorConversion
Operator that tests whether its left operand is included in the range of
values covered by search arguments.
This is the Druid version support for https://issues.apache.org/jira/browse/CALCITE-4173
SEARCH operator tests whether an operand belongs to the range set.
A RexCall to SEARCH is converted back to SQL, typically an IN or OR.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.calcite.sql.SqlOperatorReturns the SQL operator corresponding to this function.static org.apache.calcite.rex.RexNodeexpandSearch(org.apache.calcite.rex.RexCall call, org.apache.calcite.rex.RexBuilder rexBuilder, int scalarInArrayThreshold) LikeRexUtil.expandSearch(RexBuilder, RexProgram, RexNode), but with some enhancements: 1) Expands NOT IN (a.k.a.static org.apache.calcite.rex.RexNodemakeIn(org.apache.calcite.rex.RexNode arg, Collection<? extends Comparable> pointObjects, org.apache.calcite.rel.type.RelDataType pointType, boolean negate, boolean useScalarInArray, org.apache.calcite.rex.RexBuilder rexBuilder) Make an IN condition for an "arg" matching certain "points", as in "arg IN (points)".toDruidExpression(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode) Translate a CalciteRexNodeto a Druid expression.toDruidFilter(PlannerContext plannerContext, RowSignature rowSignature, VirtualColumnRegistry virtualColumnRegistry, org.apache.calcite.rex.RexNode rexNode) Returns a Druid filter corresponding to a CalciteRexNodeused as a filter condition.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.sql.calcite.expression.SqlOperatorConversion
toDruidExpressionWithPostAggOperands, toPostAggregator
-
Constructor Details
-
SearchOperatorConversion
public SearchOperatorConversion()
-
-
Method Details
-
calciteOperator
public org.apache.calcite.sql.SqlOperator calciteOperator()Description copied from interface:SqlOperatorConversionReturns the SQL operator corresponding to this function. Should be a singleton.- Specified by:
calciteOperatorin interfaceSqlOperatorConversion- Returns:
- operator
-
toDruidFilter
@Nullable public DimFilter toDruidFilter(PlannerContext plannerContext, RowSignature rowSignature, @Nullable VirtualColumnRegistry virtualColumnRegistry, org.apache.calcite.rex.RexNode rexNode) Description copied from interface:SqlOperatorConversionReturns a Druid filter corresponding to a CalciteRexNodeused as a filter condition.- Specified by:
toDruidFilterin interfaceSqlOperatorConversion- Parameters:
plannerContext- SQL planner contextrowSignature- input row signaturevirtualColumnRegistry- re-usable virtual column referencesrexNode- filter expression rex node- Returns:
- filter, or null if the call cannot be translated to a filter
-
toDruidExpression
@Nullable public DruidExpression toDruidExpression(PlannerContext plannerContext, RowSignature rowSignature, org.apache.calcite.rex.RexNode rexNode) Description copied from interface:SqlOperatorConversionTranslate a CalciteRexNodeto a Druid expression.- Specified by:
toDruidExpressionin interfaceSqlOperatorConversion- Parameters:
plannerContext- SQL planner contextrowSignature- signature of the rows to be extracted fromrexNode- expression meant to be applied on top of the rows- Returns:
- Druid expression, or null if translation is not possible
- See Also:
-
expandSearch
public static org.apache.calcite.rex.RexNode expandSearch(org.apache.calcite.rex.RexCall call, org.apache.calcite.rex.RexBuilder rexBuilder, int scalarInArrayThreshold) LikeRexUtil.expandSearch(RexBuilder, RexProgram, RexNode), but with some enhancements: 1) Expands NOT IN (a.k.a.Sarg.isComplementedPoints()as !(a || b || c) rather than (!a && !b && !c), which helps us convert it to anInDimFilterlater. 2) Can generate nice conversions for complement-points even if the range is not *entirely* complement-points. -
makeIn
@Nullable public static org.apache.calcite.rex.RexNode makeIn(org.apache.calcite.rex.RexNode arg, Collection<? extends Comparable> pointObjects, org.apache.calcite.rel.type.RelDataType pointType, boolean negate, boolean useScalarInArray, org.apache.calcite.rex.RexBuilder rexBuilder) Make an IN condition for an "arg" matching certain "points", as in "arg IN (points)".- Parameters:
arg- lhs of the INpointObjects- rhs of the IN. Must match the "pointType"pointType- type of "pointObjects"negate- true for NOT IN, false for INuseScalarInArray- if true, useScalarInArrayOperatorConversion.SQL_FUNCTIONwhen there is more than one point; if false, use a stack of ORsrexBuilder- rex builder- Returns:
- SQL rex nodes equivalent to the IN filter, or null if "pointObjects" is empty
-