Class RelBuilder
- Direct Known Subclasses:
FlinkRelBuilder
FLINK modifications are at lines
- Should be removed after fix of FLINK-29804: Lines 3000 ~ 3003
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInformation necessary to create a call to an aggregate function.static interfaceConfiguration of RelBuilder.static interfaceInformation necessary to create the GROUP BY clause of an Aggregate.static interfaceCall to a windowed aggregate function. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.calcite.plan.RelOptClusterprotected final @Nullable org.apache.calcite.plan.RelOptSchema -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRelBuilder(@Nullable org.apache.calcite.plan.Context context, org.apache.calcite.plan.RelOptCluster cluster, @Nullable org.apache.calcite.plan.RelOptSchema relOptSchema) -
Method Summary
Modifier and TypeMethodDescriptionadoptConvention(org.apache.calcite.plan.Convention convention) Returns new RelBuilder that adopts the convention provided.aggregate(RelBuilder.GroupKey groupKey, Iterable<RelBuilder.AggCall> aggCalls) Creates anAggregatewith multiple calls.aggregate(RelBuilder.GroupKey groupKey, List<org.apache.calcite.rel.core.AggregateCall> aggregateCalls) Creates anAggregatewith an array ofAggregateCalls.aggregate(RelBuilder.GroupKey groupKey, RelBuilder.AggCall... aggCalls) Creates anAggregatewith an array of calls.aggregateCall(org.apache.calcite.rel.core.AggregateCall a) Creates a call to an aggregate function as a copy of anAggregateCall.aggregateCall(org.apache.calcite.rel.core.AggregateCall a, org.apache.calcite.util.mapping.Mapping mapping) Creates a call to an aggregate function as a copy of anAggregateCall, applying a mapping.protected RelBuilder.AggCallaggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, boolean approximate, boolean ignoreNulls, @Nullable org.apache.calcite.rex.RexNode filter, @Nullable com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> distinctKeys, com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> orderKeys, @Nullable String alias, com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> operands) Creates a call to an aggregate function with all applicable operands.aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, boolean approximate, org.apache.calcite.rex.RexNode filter, @Nullable String alias, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Deprecated.aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, boolean approximate, org.apache.calcite.rex.RexNode filter, @Nullable String alias, org.apache.calcite.rex.RexNode... operands) Deprecated.aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, org.apache.calcite.rex.RexNode filter, @Nullable String alias, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Deprecated.aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, org.apache.calcite.rex.RexNode filter, @Nullable String alias, org.apache.calcite.rex.RexNode... operands) Deprecated.aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates a call to an aggregate function.aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, org.apache.calcite.rex.RexNode... operands) Creates a call to an aggregate function.org.apache.calcite.rex.RexNodeReturns an expression wrapped in an alias.org.apache.calcite.rex.RexNodeall(org.apache.calcite.rex.RexNode node, org.apache.calcite.sql.SqlOperator op, Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an ALL predicate.org.apache.calcite.rex.RexNodeCreates an AND.org.apache.calcite.rex.RexNodeand(org.apache.calcite.rex.RexNode... operands) Creates an AND.Creates an anti-join.antiJoin(org.apache.calcite.rex.RexNode... conditions) Creates an anti-join.org.apache.calcite.rex.RexSubQueryarrayQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an ARRAY sub-query.Assigns a table alias to the top entry on the stack.Creates a call to theAVGaggregate function, optionally distinct and with an alias.avg(org.apache.calcite.rex.RexNode operand) Creates a call to theAVGaggregate function.org.apache.calcite.rex.RexNodebetween(org.apache.calcite.rex.RexNode arg, org.apache.calcite.rex.RexNode lower, org.apache.calcite.rex.RexNode upper) Creates aBETWEEN.org.apache.calcite.rel.RelNodebuild()Returns the final relational expression.org.apache.calcite.rex.RexNodecall(org.apache.calcite.sql.SqlOperator operator, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates a call to a scalar operator.org.apache.calcite.rex.RexNodecall(org.apache.calcite.sql.SqlOperator operator, org.apache.calcite.rex.RexNode... operands) Creates a call to a scalar operator.org.apache.calcite.rex.RexNodecast(org.apache.calcite.rex.RexNode expr, org.apache.calcite.sql.type.SqlTypeName typeName) Creates an expression that casts an expression to a given type.org.apache.calcite.rex.RexNodecast(org.apache.calcite.rex.RexNode expr, org.apache.calcite.sql.type.SqlTypeName typeName, int precision) Creates an expression that casts an expression to a type with a given name and precision or length.org.apache.calcite.rex.RexNodecast(org.apache.calcite.rex.RexNode expr, org.apache.calcite.sql.type.SqlTypeName typeName, int precision, int scale) Creates an expression that casts an expression to a type with a given name, precision and scale.voidclear()Clears the stack.convert(org.apache.calcite.rel.type.RelDataType castRowType, boolean rename) Creates a projection that converts the current relational expression's output to a desired row type.correlate(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rel.core.CorrelationId correlationId, Iterable<? extends org.apache.calcite.rex.RexNode> requiredFields) Creates aCorrelatewith aCorrelationIdand a list of fields that are used by correlation.correlate(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rel.core.CorrelationId correlationId, org.apache.calcite.rex.RexNode... requiredFields) Creates aCorrelatewith aCorrelationIdand an array of fields that are used by correlation.count(boolean distinct, @Nullable String alias, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates a call to theCOUNTaggregate function, optionally distinct and with an alias.Creates a call to theCOUNTaggregate function, optionally distinct and with an alias.Creates a call to theCOUNTaggregate function.count(org.apache.calcite.rex.RexNode... operands) Creates a call to theCOUNTaggregate function.Creates a call to theCOUNT(*)aggregate function.static RelBuildercreate(org.apache.calcite.tools.FrameworkConfig config) Creates a RelBuilder.org.apache.calcite.rex.RexWindowBoundCreates aCURRENT ROWwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound).org.apache.calcite.rex.RexNodecursor(int inputCount, int ordinal) Creates a RexCall to theCURSORfunction by ordinal.org.apache.calcite.rex.RexNodedesc(org.apache.calcite.rex.RexNode node) Converts a sort expression to descending.distinct()Creates anAggregatethat makes the relational expression distinct on all fields.org.apache.calcite.rex.RexNodedot(org.apache.calcite.rex.RexNode node, int fieldOrdinal) Creates an access to a field by ordinal.org.apache.calcite.rex.RexNodeCreates an access to a field by name.empty()Creates a relational expression that reads from an input and throws all of the rows away.org.apache.calcite.rex.RexNodeequals(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates an=.exchange(org.apache.calcite.rel.RelDistribution distribution) Creates an Exchange by distribution.org.apache.calcite.rex.RexSubQueryexists(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an EXISTS predicate.org.apache.calcite.rex.RexInputReffield(int fieldOrdinal) Creates a reference to an input field by ordinal.org.apache.calcite.rex.RexInputReffield(int inputCount, int inputOrdinal, int fieldOrdinal) Creates a reference to a field of a given input relational expression by ordinal.org.apache.calcite.rex.RexInputRefCreates a reference to a field of given input relational expression by name.org.apache.calcite.rex.RexNodeCreates a reference to a field which originated in a relation with the given alias.org.apache.calcite.rex.RexInputRefCreates a reference to a field by name.org.apache.calcite.rex.RexNodeCreates a reference to a field of the current record which originated in a relation with a given alias.org.apache.calcite.rex.RexNodeReturns a reference to a given field of a record-valued expression.com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode>fields()Returns references to the fields of the top input.com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode>fields(int inputCount, int inputOrdinal) Returns references to the fields of a given input.com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode>Returns references to fields identified by name.com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode>Returns references to fields for a given list of input ordinals.com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode>fields(org.apache.calcite.rel.RelCollation collation) Returns references to fields for a given collation.com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode>fields(org.apache.calcite.util.ImmutableBitSet ordinals) Returns references to fields for a given bit set of input ordinals.com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode>fields(org.apache.calcite.util.mapping.Mappings.TargetMapping mapping) Returns references to fields identified by a mapping.Creates aFilterof a list of predicates.filter(Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet, Iterable<? extends org.apache.calcite.rex.RexNode> predicates) Creates aFilterof a list of correlation variables and a list of predicates.filter(Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet, org.apache.calcite.rex.RexNode... predicates) Creates aFilterof a list of correlation variables and an array of predicates.filter(org.apache.calcite.rex.RexNode... predicates) Creates aFilterof an array of predicates.org.apache.calcite.rex.RexWindowBoundfollowing(org.apache.calcite.rex.RexNode bound) Creates abound FOLLOWINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound).functionScan(org.apache.calcite.sql.SqlOperator operator, int inputCount, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates aTableFunctionScan.functionScan(org.apache.calcite.sql.SqlOperator operator, int inputCount, org.apache.calcite.rex.RexNode... operands) Creates aTableFunctionScan.org.apache.calcite.plan.RelOptCluster@Nullable org.apache.calcite.plan.RelOptSchemaorg.apache.calcite.rex.RexBuilderReturns the builder forRexNodeexpressions.org.apache.calcite.rel.core.RelFactories.TableScanFactoryorg.apache.calcite.rel.type.RelDataTypeFactoryReturns the type factory.org.apache.calcite.rex.RexNodegreaterThan(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a>.org.apache.calcite.rex.RexNodegreaterThanOrEqual(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a>=.groupKey()Creates an empty group key.groupKey(int... fieldOrdinals) Creates a group key of fields identified by ordinal.Creates a group key.groupKey(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, boolean indicator, Iterable<? extends Iterable<? extends org.apache.calcite.rex.RexNode>> nodeLists) Deprecated.groupKey(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends Iterable<? extends org.apache.calcite.rex.RexNode>> nodeLists) Creates a group key with grouping sets.Creates a group key of fields identified by name.groupKey(org.apache.calcite.rex.RexNode... nodes) Creates a group key.groupKey(org.apache.calcite.util.ImmutableBitSet groupSet) Creates a group key, identified by field positions in the underlying relational expression.groupKey(org.apache.calcite.util.ImmutableBitSet groupSet, boolean indicator, @Nullable com.google.common.collect.ImmutableList<org.apache.calcite.util.ImmutableBitSet> groupSets) Deprecated.groupKey(org.apache.calcite.util.ImmutableBitSet groupSet, Iterable<? extends org.apache.calcite.util.ImmutableBitSet> groupSets) Creates a group key with grouping sets, both identified by field positions in the underlying relational expression.Attaches multiple hints to the stack top relational expression.hints(org.apache.calcite.rel.hint.RelHint... hints) Attaches an array of hints to the stack top relational expression.org.apache.calcite.rex.RexSubQueryCreates an IN predicate with a sub-query.org.apache.calcite.rex.RexNodeCreates an IN predicate with a list of values.org.apache.calcite.rex.RexNodein(org.apache.calcite.rex.RexNode arg, Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an IN predicate with a sub-query.org.apache.calcite.rex.RexNodein(org.apache.calcite.rex.RexNode arg, org.apache.calcite.rex.RexNode... ranges) Creates an IN predicate with a list of values.intersect(boolean all) Creates anIntersectof the two most recent relational expressions on the stack.intersect(boolean all, int n) Creates anIntersectof thenmost recent relational expressions on the stack.org.apache.calcite.rex.RexNodeisDistinctFrom(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates an expression equivalent too0 IS DISTINCT FROM o1.org.apache.calcite.rex.RexNodeisNotDistinctFrom(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates an expression equivalent to "o0 IS NOT DISTINCT FROM o1".org.apache.calcite.rex.RexNodeisNotNull(org.apache.calcite.rex.RexNode operand) Creates anIS NOT NULL.org.apache.calcite.rex.RexNodeisNull(org.apache.calcite.rex.RexNode operand) Creates abIS NULL.join(org.apache.calcite.rel.core.JoinRelType joinType, Iterable<? extends org.apache.calcite.rex.RexNode> conditions) Creates aJoinwith multiple conditions.Creates aJoinusing USING syntax.join(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rex.RexNode condition) Creates aJoinwith one condition.join(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rex.RexNode condition, Set<org.apache.calcite.rel.core.CorrelationId> variablesSet) Creates aJoinwith correlating variables.join(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rex.RexNode condition0, org.apache.calcite.rex.RexNode... conditions) Creates aJoinwith an array of conditions.org.apache.calcite.rex.RexNodelessThan(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a<.org.apache.calcite.rex.RexNodelessThanOrEqual(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a<=.<R> Rlet(Function<RelBuilder, R> consumer) Performs an action on this RelBuilder.limit(int offset, int fetch) Creates a limit without a sort.org.apache.calcite.rex.RexLiteralCreates a literal (constant expression).org.apache.calcite.rex.RexSubQuerymapQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a MAP sub-query.match(org.apache.calcite.rex.RexNode pattern, boolean strictStart, boolean strictEnd, Map<String, org.apache.calcite.rex.RexNode> patternDefinitions, Iterable<? extends org.apache.calcite.rex.RexNode> measureList, org.apache.calcite.rex.RexNode after, Map<String, ? extends SortedSet<String>> subsets, boolean allRows, Iterable<? extends org.apache.calcite.rex.RexNode> partitionKeys, Iterable<? extends org.apache.calcite.rex.RexNode> orderKeys, org.apache.calcite.rex.RexNode interval) Creates aMatch.Creates a call to theMAXaggregate function.max(org.apache.calcite.rex.RexNode operand) Creates a call to theMAXaggregate function, optionally with an alias.Creates a call to theMINaggregate function, optionally with an alias.min(org.apache.calcite.rex.RexNode operand) Creates a call to theMINaggregate function.minus(boolean all) Creates aMinusof the two most recent relational expressions on the stack.minus(boolean all, int n) Creates aMinusof thenmost recent relational expressions on the stack.org.apache.calcite.rex.RexSubQuerymultisetQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a MULTISET sub-query.org.apache.calcite.rex.RexNodenot(org.apache.calcite.rex.RexNode operand) Creates a NOT.org.apache.calcite.rex.RexNodenotEquals(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a<>.org.apache.calcite.rex.RexNodenullsFirst(org.apache.calcite.rex.RexNode node) Converts a sort expression to nulls first.org.apache.calcite.rex.RexNodenullsLast(org.apache.calcite.rex.RexNode node) Converts a sort expression to nulls last.org.apache.calcite.rex.RexNodeCreates an OR.org.apache.calcite.rex.RexNodeor(org.apache.calcite.rex.RexNode... operands) Creates an OR.org.apache.calcite.rex.RexNodepatternAlter(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that creates alternate patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternAlter(org.apache.calcite.rex.RexNode... nodes) Creates a call that creates alternate patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternConcat(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that concatenates patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternConcat(org.apache.calcite.rex.RexNode... nodes) Creates a call that concatenates patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternExclude(org.apache.calcite.rex.RexNode node) Creates a call that creates an exclude pattern; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternField(String alpha, org.apache.calcite.rel.type.RelDataType type, int i) Creates a reference to a given field of the pattern.org.apache.calcite.rex.RexNodepatternPermute(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that creates permute patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternPermute(org.apache.calcite.rex.RexNode... nodes) Creates a call that creates permute patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternQuantify(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that creates quantify patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rex.RexNodepatternQuantify(org.apache.calcite.rex.RexNode... nodes) Creates a call that creates quantify patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode).org.apache.calcite.rel.RelNodepeek()Returns the relational expression at the top of the stack, but does not remove it.org.apache.calcite.rel.RelNodepeek(int n) Returns the relational expressionnpositions from the top of the stack, but does not remove it.org.apache.calcite.rel.RelNodepeek(int inputCount, int inputOrdinal) Returns the relational expressionnpositions from the top of the stack, but does not remove it.permute(org.apache.calcite.util.mapping.Mapping mapping) pivot(RelBuilder.GroupKey groupKey, Iterable<? extends RelBuilder.AggCall> aggCalls, Iterable<? extends org.apache.calcite.rex.RexNode> axes, Iterable<? extends Map.Entry<String, ? extends Iterable<? extends org.apache.calcite.rex.RexNode>>> values) Creates a Pivot.org.apache.calcite.rex.RexWindowBoundpreceding(org.apache.calcite.rex.RexNode bound) Creates abound PRECEDINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound).Creates aProjectof the given list of expressions.project(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends @Nullable String> fieldNames) Creates aProjectof the given list of expressions and field names.project(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends @Nullable String> fieldNames, boolean force) Creates aProjectof the given list of expressions, using the given names.project(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends @Nullable String> fieldNames, boolean force, Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet) The same withproject(Iterable, Iterable, boolean), with additional variablesSet param.project(org.apache.calcite.rex.RexNode... nodes) Creates aProjectof the given expressions.projectExcept(Iterable<org.apache.calcite.rex.RexNode> expressions) Creates aProjectof all original fields, except the given list of expressions.projectExcept(org.apache.calcite.rex.RexNode... expressions) Creates aProjectof all original fields, except the given expressions.projectNamed(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, @Nullable Iterable<? extends @Nullable String> fieldNames, boolean force) Creates aProjectof the given expressions and field names, and optionally optimizing.projectNamed(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, @Nullable Iterable<? extends @Nullable String> fieldNames, boolean force, Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet) Creates aProjectof the given expressions and field names, and optionally optimizing.projectPlus(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates aProjectof all original fields, plus the given list of expressions.projectPlus(org.apache.calcite.rex.RexNode... nodes) Creates aProjectof all original fields, plus the given expressions.static org.apache.calcite.tools.RelBuilderFactoryCreates aRelBuilderFactorythat uses a given set of factories.static org.apache.calcite.tools.RelBuilderFactoryproto(org.apache.calcite.plan.Context context) Creates aRelBuilderFactory, a partially-created RelBuilder.push(org.apache.calcite.rel.RelNode node) Adds a relational expression to be the input to the next relational expression constructed.Pushes a collection of relational expressions.Ensures that the field names match those given.repeatUnion(String tableName, boolean all) Creates aRepeatUnionassociated to aTransientTablewithout a maximum number of iterations, i.e. repeatUnion(tableName, all, -1).repeatUnion(String tableName, boolean all, int iterationLimit) Creates aRepeatUnionassociated to aTransientTableof the two most recent relational expressions on the stack.org.apache.calcite.rex.RexSubQueryscalarQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a scalar sub-query.Creates aTableScanof the table with a given name.Creates aTableScanof the table with a given name.Creates aJoinwithJoinRelType.SEMI.semiJoin(org.apache.calcite.rex.RexNode... conditions) Creates aJoinwithJoinRelType.SEMI.intsize()Returns the size of the stack.snapshot(org.apache.calcite.rex.RexNode period) Creates aSnapshotof a given snapshot period.org.apache.calcite.rex.RexSubQuerysome(org.apache.calcite.rex.RexNode node, org.apache.calcite.sql.SqlOperator op, Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a SOME (or ANY) predicate.sort(int... fields) Creates aSortby field ordinals.Creates aSortby expressions.sort(org.apache.calcite.rel.RelCollation collation) Creates aSortby specifying collations.sort(org.apache.calcite.rex.RexNode... nodes) Creates aSortby expressions.sortExchange(org.apache.calcite.rel.RelDistribution distribution, org.apache.calcite.rel.RelCollation collation) Creates a SortExchange by distribution and collation.Creates aSortby a list of expressions, with limit and offset.sortLimit(int offset, int fetch, org.apache.calcite.rex.RexNode... nodes) Creates aSortby expressions, with limit and offset.sortLimit(@Nullable org.apache.calcite.rex.RexNode offsetNode, @Nullable org.apache.calcite.rex.RexNode fetchNode, Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates aSortby a list of expressions, with limitNode and offsetNode.Creates a call to theSUMaggregate function, optionally distinct and with an alias.sum(org.apache.calcite.rex.RexNode operand) Creates a call to theSUMaggregate function.toString()Converts this RelBuilder to a string.transform(UnaryOperator<RelBuilder.Config> transform) Creates a copy of this RelBuilder, with the same state as this, applying a transform to the config.transientScan(String tableName) Creates aTableScanon aTransientTablewith the given name, using as type the top of the stack's type.transientScan(String tableName, org.apache.calcite.rel.type.RelDataType rowType) Creates aTableScanon aTransientTablewith the given name and type.org.apache.calcite.rex.RexWindowBoundCreates anUNBOUNDED FOLLOWINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound).org.apache.calcite.rex.RexWindowBoundCreates anUNBOUNDED PRECEDINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound).Creates anUncollectwith given item aliases.union(boolean all) Creates aUnionof the two most recent relational expressions on the stack.union(boolean all, int n) Creates aUnionof thenmost recent relational expressions on the stack.org.apache.calcite.rex.RexSubQueryunique(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a UNIQUE predicate.unpivot(boolean includeNulls, Iterable<String> measureNames, Iterable<String> axisNames, Iterable<? extends Map.Entry<? extends List<? extends org.apache.calcite.rex.RexLiteral>, ? extends List<? extends org.apache.calcite.rex.RexNode>>> axisMap) Creates an Unpivot.Creates aValues.values(Iterable<? extends List<org.apache.calcite.rex.RexLiteral>> tupleList, org.apache.calcite.rel.type.RelDataType rowType) Creates aValueswith a specified row type.values(org.apache.calcite.rel.type.RelDataType rowType) Creates aValueswith a specified row type and zero rows.Creates aValueswith a specified row type.variable(org.apache.calcite.util.Holder<org.apache.calcite.rex.RexCorrelVariable> v) Creates a correlation variable for the current input, and writes it into a Holder.<E> Ewith(org.apache.calcite.rel.RelNode r, Function<RelBuilder, E> fn) Evaluates an expression with a relational expression temporarily on the stack.<E> EwithPredicates(org.apache.calcite.rel.metadata.RelMetadataQuery mq, Function<RelBuilder, E> fn) Performs an action using predicates of thecurrent nodeto simplify.<E> EwithSimplifier(BiFunction<RelBuilder, org.apache.calcite.rex.RexSimplify, org.apache.calcite.rex.RexSimplify> simplifierTransform, Function<RelBuilder, E> fn) Performs an action with a temporary simplifier.
-
Field Details
-
cluster
protected final org.apache.calcite.plan.RelOptCluster cluster -
relOptSchema
protected final @Nullable org.apache.calcite.plan.RelOptSchema relOptSchema
-
-
Constructor Details
-
RelBuilder
protected RelBuilder(@Nullable org.apache.calcite.plan.Context context, org.apache.calcite.plan.RelOptCluster cluster, @Nullable org.apache.calcite.plan.RelOptSchema relOptSchema)
-
-
Method Details
-
create
Creates a RelBuilder. -
transform
Creates a copy of this RelBuilder, with the same state as this, applying a transform to the config. -
let
Performs an action on this RelBuilder.For example, consider the following code:
RelNode filterAndRename(RelBuilder relBuilder, RelNode rel, RexNode condition, List<String> fieldNames) { relBuilder.push(rel) .filter(condition); if (fieldNames != null) { relBuilder.rename(fieldNames); } return relBuilder .build();The pipeline is disrupted by the 'if'. The
letmethod allows you to perform the flow as a single pipeline:RelNode filterAndRename(RelBuilder relBuilder, RelNode rel, RexNode condition, List<String> fieldNames) { return relBuilder.push(rel) .filter(condition) .let(r -> fieldNames == null ? r : r.rename(fieldNames)) .build();In pipelined cases such as this one, the lambda must return this RelBuilder. But
letreturn values of other types. -
toString
Converts this RelBuilder to a string. The string is the string representation of all of the RelNodes on the stack. -
getTypeFactory
public org.apache.calcite.rel.type.RelDataTypeFactory getTypeFactory()Returns the type factory. -
adoptConvention
Returns new RelBuilder that adopts the convention provided. RelNode will be created with such convention if corresponding factory is provided. -
getRexBuilder
public org.apache.calcite.rex.RexBuilder getRexBuilder()Returns the builder forRexNodeexpressions. -
proto
public static org.apache.calcite.tools.RelBuilderFactory proto(org.apache.calcite.plan.Context context) Creates aRelBuilderFactory, a partially-created RelBuilder. Just add aRelOptClusterand aRelOptSchema -
proto
Creates aRelBuilderFactorythat uses a given set of factories. -
getCluster
public org.apache.calcite.plan.RelOptCluster getCluster() -
getRelOptSchema
public @Nullable org.apache.calcite.plan.RelOptSchema getRelOptSchema() -
getScanFactory
public org.apache.calcite.rel.core.RelFactories.TableScanFactory getScanFactory() -
push
Adds a relational expression to be the input to the next relational expression constructed.This method is usual when you want to weave in relational expressions that are not supported by the builder. If, while creating such expressions, you need to use previously built expressions as inputs, call
build()to pop those inputs. -
pushAll
Pushes a collection of relational expressions. -
size
public int size()Returns the size of the stack. -
build
public org.apache.calcite.rel.RelNode build()Returns the final relational expression.Throws if the stack is empty.
-
peek
public org.apache.calcite.rel.RelNode peek()Returns the relational expression at the top of the stack, but does not remove it. -
peek
public org.apache.calcite.rel.RelNode peek(int n) Returns the relational expressionnpositions from the top of the stack, but does not remove it. -
peek
public org.apache.calcite.rel.RelNode peek(int inputCount, int inputOrdinal) Returns the relational expressionnpositions from the top of the stack, but does not remove it. -
with
Evaluates an expression with a relational expression temporarily on the stack. -
withSimplifier
public <E> E withSimplifier(BiFunction<RelBuilder, org.apache.calcite.rex.RexSimplify, org.apache.calcite.rex.RexSimplify> simplifierTransform, Function<RelBuilder, E> fn) Performs an action with a temporary simplifier. -
withPredicates
public <E> E withPredicates(org.apache.calcite.rel.metadata.RelMetadataQuery mq, Function<RelBuilder, E> fn) Performs an action using predicates of thecurrent nodeto simplify. -
literal
Creates a literal (constant expression). -
variable
public RelBuilder variable(org.apache.calcite.util.Holder<org.apache.calcite.rex.RexCorrelVariable> v) Creates a correlation variable for the current input, and writes it into a Holder. -
field
Creates a reference to a field by name.Equivalent to
field(1, 0, fieldName).- Parameters:
fieldName- Field name
-
field
Creates a reference to a field of given input relational expression by name.- Parameters:
inputCount- Number of inputsinputOrdinal- Input ordinalfieldName- Field name
-
field
public org.apache.calcite.rex.RexInputRef field(int fieldOrdinal) Creates a reference to an input field by ordinal.Equivalent to
field(1, 0, ordinal).- Parameters:
fieldOrdinal- Field ordinal
-
field
public org.apache.calcite.rex.RexInputRef field(int inputCount, int inputOrdinal, int fieldOrdinal) Creates a reference to a field of a given input relational expression by ordinal.- Parameters:
inputCount- Number of inputsinputOrdinal- Input ordinalfieldOrdinal- Field ordinal within input
-
field
Creates a reference to a field of the current record which originated in a relation with a given alias. -
field
Creates a reference to a field which originated in a relation with the given alias. Searches for the relation starting at the top of the stack. -
field
Returns a reference to a given field of a record-valued expression. -
fields
public com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> fields()Returns references to the fields of the top input. -
fields
public com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> fields(int inputCount, int inputOrdinal) Returns references to the fields of a given input. -
fields
public com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> fields(org.apache.calcite.rel.RelCollation collation) Returns references to fields for a given collation. -
fields
public com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> fields(List<? extends Number> ordinals) Returns references to fields for a given list of input ordinals. -
fields
public com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> fields(org.apache.calcite.util.ImmutableBitSet ordinals) Returns references to fields for a given bit set of input ordinals. -
fields
public com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> fields(Iterable<String> fieldNames) Returns references to fields identified by name. -
fields
public com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> fields(org.apache.calcite.util.mapping.Mappings.TargetMapping mapping) Returns references to fields identified by a mapping. -
dot
Creates an access to a field by name. -
dot
public org.apache.calcite.rex.RexNode dot(org.apache.calcite.rex.RexNode node, int fieldOrdinal) Creates an access to a field by ordinal. -
call
public org.apache.calcite.rex.RexNode call(org.apache.calcite.sql.SqlOperator operator, org.apache.calcite.rex.RexNode... operands) Creates a call to a scalar operator. -
call
public org.apache.calcite.rex.RexNode call(org.apache.calcite.sql.SqlOperator operator, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates a call to a scalar operator. -
in
public org.apache.calcite.rex.RexNode in(org.apache.calcite.rex.RexNode arg, org.apache.calcite.rex.RexNode... ranges) Creates an IN predicate with a list of values.For example,
is equivalent to SQLb.scan("Emp") .filter(b.in(b.field("deptno"), b.literal(10), b.literal(20)))SELECT * FROM Emp WHERE deptno IN (10, 20) -
in
public org.apache.calcite.rex.RexNode in(org.apache.calcite.rex.RexNode arg, Iterable<? extends org.apache.calcite.rex.RexNode> ranges) Creates an IN predicate with a list of values.For example,
b.scan("Emps") .filter( b.in(b.field("deptno"), Arrays.asList(b.literal(10), b.literal(20))))is equivalent to the SQL
SELECT * FROM Emps WHERE deptno IN (10, 20) -
in
public org.apache.calcite.rex.RexSubQuery in(org.apache.calcite.rel.RelNode rel, Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates an IN predicate with a sub-query. -
in
public org.apache.calcite.rex.RexNode in(org.apache.calcite.rex.RexNode arg, Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an IN predicate with a sub-query.For example,
b.scan("Emps") .filter( b.in(b.field("deptno"), b2 -> b2.scan("Depts") .filter( b2.eq(b2.field("location"), b2.literal("Boston"))) .project(b.field("deptno")) .build()))is equivalent to the SQL
SELECT * FROM Emps WHERE deptno IN (SELECT deptno FROM Dept WHERE location = 'Boston') -
some
public org.apache.calcite.rex.RexSubQuery some(org.apache.calcite.rex.RexNode node, org.apache.calcite.sql.SqlOperator op, Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a SOME (or ANY) predicate.For example,
b.scan("Emps") .filter( b.some(b.field("commission"), SqlStdOperatorTable.GREATER_THAN, b2 -> b2.scan("Emps") .filter( b2.eq(b2.field("job"), b2.literal("Manager"))) .project(b2.field("sal")) .build()))is equivalent to the SQL
SELECT * FROM Emps WHERE commission > SOME (SELECT sal FROM Emps WHERE job = 'Manager')or (since
SOMEandANYare synonyms) the SQLSELECT * FROM Emps WHERE commission > ANY (SELECT sal FROM Emps WHERE job = 'Manager') -
all
public org.apache.calcite.rex.RexNode all(org.apache.calcite.rex.RexNode node, org.apache.calcite.sql.SqlOperator op, Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an ALL predicate.For example,
b.scan("Emps") .filter( b.all(b.field("commission"), SqlStdOperatorTable.GREATER_THAN, b2 -> b2.scan("Emps") .filter( b2.eq(b2.field("job"), b2.literal("Manager"))) .project(b2.field("sal")) .build()))is equivalent to the SQL
SELECT * FROM Emps WHERE commission > ALL (SELECT sal FROM Emps WHERE job = 'Manager')Calcite translates
ALLpredicates toNOT SOME. The following SQL is equivalent to the previous:SELECT * FROM Emps WHERE NOT (commission <= SOME (SELECT sal FROM Emps WHERE job = 'Manager')) -
exists
public org.apache.calcite.rex.RexSubQuery exists(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an EXISTS predicate.For example,
b.scan("Depts") .filter( b.exists(b2 -> b2.scan("Emps") .filter( b2.eq(b2.field("job"), b2.literal("Manager"))) .build()))is equivalent to the SQL
SELECT * FROM Depts WHERE EXISTS (SELECT 1 FROM Emps WHERE job = 'Manager') -
unique
public org.apache.calcite.rex.RexSubQuery unique(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a UNIQUE predicate.For example,
b.scan("Depts") .filter( b.exists(b2 -> b2.scan("Emps") .filter( b2.eq(b2.field("job"), b2.literal("Manager"))) .project(b2.field("deptno") .build()))is equivalent to the SQL
SELECT * FROM Depts WHERE UNIQUE (SELECT deptno FROM Emps WHERE job = 'Manager') -
scalarQuery
public org.apache.calcite.rex.RexSubQuery scalarQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a scalar sub-query.For example,
b.scan("Depts") .project( b.field("deptno") b.scalarQuery(b2 -> b2.scan("Emps") .aggregate( b2.eq(b2.field("job"), b2.literal("Manager"))) .build()))is equivalent to the SQL
SELECT deptno, (SELECT MAX(sal) FROM Emps) FROM Depts -
arrayQuery
public org.apache.calcite.rex.RexSubQuery arrayQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates an ARRAY sub-query.For example,
b.scan("Depts") .project( b.field("deptno") b.arrayQuery(b2 -> b2.scan("Emps") .build()))is equivalent to the SQL
SELECT deptno, ARRAY (SELECT * FROM Emps) FROM Depts -
multisetQuery
public org.apache.calcite.rex.RexSubQuery multisetQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a MULTISET sub-query.For example,
b.scan("Depts") .project( b.field("deptno") b.multisetQuery(b2 -> b2.scan("Emps") .build()))is equivalent to the SQL
SELECT deptno, MULTISET (SELECT * FROM Emps) FROM Depts -
mapQuery
public org.apache.calcite.rex.RexSubQuery mapQuery(Function<RelBuilder, org.apache.calcite.rel.RelNode> f) Creates a MAP sub-query.For example,
b.scan("Depts") .project( b.field("deptno") b.multisetQuery(b2 -> b2.scan("Emps") .project(b2.field("empno"), b2.field("job")) .build()))is equivalent to the SQL
SELECT deptno, MAP (SELECT empno, job FROM Emps) FROM Depts -
and
public org.apache.calcite.rex.RexNode and(org.apache.calcite.rex.RexNode... operands) Creates an AND. -
and
public org.apache.calcite.rex.RexNode and(Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates an AND.Simplifies the expression a little:
e AND TRUEbecomese;e AND e2 AND NOT ebecomese2. -
or
public org.apache.calcite.rex.RexNode or(org.apache.calcite.rex.RexNode... operands) Creates an OR. -
or
public org.apache.calcite.rex.RexNode or(Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates an OR. -
not
public org.apache.calcite.rex.RexNode not(org.apache.calcite.rex.RexNode operand) Creates a NOT. -
equals
public org.apache.calcite.rex.RexNode equals(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates an=. -
greaterThan
public org.apache.calcite.rex.RexNode greaterThan(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a>. -
greaterThanOrEqual
public org.apache.calcite.rex.RexNode greaterThanOrEqual(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a>=. -
lessThan
public org.apache.calcite.rex.RexNode lessThan(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a<. -
lessThanOrEqual
public org.apache.calcite.rex.RexNode lessThanOrEqual(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a<=. -
notEquals
public org.apache.calcite.rex.RexNode notEquals(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates a<>. -
isNotDistinctFrom
public org.apache.calcite.rex.RexNode isNotDistinctFrom(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates an expression equivalent to "o0 IS NOT DISTINCT FROM o1". It is also equivalent to "o0 = o1 OR (o0 IS NULL AND o1 IS NULL)". -
isDistinctFrom
public org.apache.calcite.rex.RexNode isDistinctFrom(org.apache.calcite.rex.RexNode operand0, org.apache.calcite.rex.RexNode operand1) Creates an expression equivalent too0 IS DISTINCT FROM o1. It is also equivalent to "NOT (o0 = o1 OR (o0 IS NULL AND o1 IS NULL)). -
between
public org.apache.calcite.rex.RexNode between(org.apache.calcite.rex.RexNode arg, org.apache.calcite.rex.RexNode lower, org.apache.calcite.rex.RexNode upper) Creates aBETWEEN. -
isNull
public org.apache.calcite.rex.RexNode isNull(org.apache.calcite.rex.RexNode operand) Creates abIS NULL. -
isNotNull
public org.apache.calcite.rex.RexNode isNotNull(org.apache.calcite.rex.RexNode operand) Creates anIS NOT NULL. -
cast
public org.apache.calcite.rex.RexNode cast(org.apache.calcite.rex.RexNode expr, org.apache.calcite.sql.type.SqlTypeName typeName) Creates an expression that casts an expression to a given type. -
cast
public org.apache.calcite.rex.RexNode cast(org.apache.calcite.rex.RexNode expr, org.apache.calcite.sql.type.SqlTypeName typeName, int precision) Creates an expression that casts an expression to a type with a given name and precision or length. -
cast
public org.apache.calcite.rex.RexNode cast(org.apache.calcite.rex.RexNode expr, org.apache.calcite.sql.type.SqlTypeName typeName, int precision, int scale) Creates an expression that casts an expression to a type with a given name, precision and scale. -
alias
Returns an expression wrapped in an alias.This method is idempotent: If the expression is already wrapped in the correct alias, does nothing; if wrapped in an incorrect alias, removes the incorrect alias and applies the correct alias.
-
desc
public org.apache.calcite.rex.RexNode desc(org.apache.calcite.rex.RexNode node) Converts a sort expression to descending. -
nullsLast
public org.apache.calcite.rex.RexNode nullsLast(org.apache.calcite.rex.RexNode node) Converts a sort expression to nulls last. -
nullsFirst
public org.apache.calcite.rex.RexNode nullsFirst(org.apache.calcite.rex.RexNode node) Converts a sort expression to nulls first. -
unboundedPreceding
public org.apache.calcite.rex.RexWindowBound unboundedPreceding()Creates anUNBOUNDED PRECEDINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound). -
preceding
public org.apache.calcite.rex.RexWindowBound preceding(org.apache.calcite.rex.RexNode bound) Creates abound PRECEDINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound). -
currentRow
public org.apache.calcite.rex.RexWindowBound currentRow()Creates aCURRENT ROWwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound). -
following
public org.apache.calcite.rex.RexWindowBound following(org.apache.calcite.rex.RexNode bound) Creates abound FOLLOWINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound). -
unboundedFollowing
public org.apache.calcite.rex.RexWindowBound unboundedFollowing()Creates anUNBOUNDED FOLLOWINGwindow bound, for use in methods such asRelBuilder.OverCall.rowsFrom(RexWindowBound)andRelBuilder.OverCall.rangeBetween(RexWindowBound, RexWindowBound). -
groupKey
Creates an empty group key. -
groupKey
Creates a group key. -
groupKey
Creates a group key. -
groupKey
public RelBuilder.GroupKey groupKey(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends Iterable<? extends org.apache.calcite.rex.RexNode>> nodeLists) Creates a group key with grouping sets. -
groupKey
@Deprecated public RelBuilder.GroupKey groupKey(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, boolean indicator, Iterable<? extends Iterable<? extends org.apache.calcite.rex.RexNode>> nodeLists) Deprecated.Now that indicator is deprecated, usegroupKey(Iterable, Iterable), which has the same behavior as calling this method withindicator = false. -
groupKey
Creates a group key of fields identified by ordinal. -
groupKey
Creates a group key of fields identified by name. -
groupKey
Creates a group key, identified by field positions in the underlying relational expression.This method of creating a group key does not allow you to group on new expressions, only column projections, but is efficient, especially when you are coming from an existing
Aggregate. -
groupKey
public RelBuilder.GroupKey groupKey(org.apache.calcite.util.ImmutableBitSet groupSet, Iterable<? extends org.apache.calcite.util.ImmutableBitSet> groupSets) Creates a group key with grouping sets, both identified by field positions in the underlying relational expression.This method of creating a group key does not allow you to group on new expressions, only column projections, but is efficient, especially when you are coming from an existing
Aggregate.It is possible for
groupSetto be strict superset of allgroupSets. For example, in the pseudo SQLGROUP BY 0, 1, 2 GROUPING SETS ((0, 1), 0)column 2 does not appear in either grouping set. This is not valid SQL. We can approximate in actual SQL by adding an extra grouping set and filtering out using
HAVING, as follows:GROUP BY GROUPING SETS ((0, 1, 2), (0, 1), 0) HAVING GROUPING_ID(0, 1, 2) <> 0 -
groupKey
@Deprecated public RelBuilder.GroupKey groupKey(org.apache.calcite.util.ImmutableBitSet groupSet, boolean indicator, @Nullable com.google.common.collect.ImmutableList<org.apache.calcite.util.ImmutableBitSet> groupSets) Deprecated. -
aggregateCall
@Deprecated public RelBuilder.AggCall aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, org.apache.calcite.rex.RexNode filter, @Nullable String alias, org.apache.calcite.rex.RexNode... operands) Deprecated. -
aggregateCall
@Deprecated public RelBuilder.AggCall aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, boolean approximate, org.apache.calcite.rex.RexNode filter, @Nullable String alias, org.apache.calcite.rex.RexNode... operands) Deprecated. -
aggregateCall
@Deprecated public RelBuilder.AggCall aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, org.apache.calcite.rex.RexNode filter, @Nullable String alias, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Deprecated. -
aggregateCall
@Deprecated public RelBuilder.AggCall aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, boolean approximate, org.apache.calcite.rex.RexNode filter, @Nullable String alias, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Deprecated. -
aggregateCall
public RelBuilder.AggCall aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates a call to an aggregate function.To add other operands, apply
RelBuilder.AggCall.distinct(),RelBuilder.AggCall.approximate(boolean),filter(RexNode...),RelBuilder.AggCall.sort(java.lang.Iterable<org.apache.calcite.rex.RexNode>),RelBuilder.AggCall.as(java.lang.String)to the result. -
aggregateCall
public RelBuilder.AggCall aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, org.apache.calcite.rex.RexNode... operands) Creates a call to an aggregate function.To add other operands, apply
RelBuilder.AggCall.distinct(),RelBuilder.AggCall.approximate(boolean),filter(RexNode...),RelBuilder.AggCall.sort(java.lang.Iterable<org.apache.calcite.rex.RexNode>),RelBuilder.AggCall.as(java.lang.String)to the result. -
aggregateCall
Creates a call to an aggregate function as a copy of anAggregateCall. -
aggregateCall
public RelBuilder.AggCall aggregateCall(org.apache.calcite.rel.core.AggregateCall a, org.apache.calcite.util.mapping.Mapping mapping) Creates a call to an aggregate function as a copy of anAggregateCall, applying a mapping. -
aggregateCall
protected RelBuilder.AggCall aggregateCall(org.apache.calcite.sql.SqlAggFunction aggFunction, boolean distinct, boolean approximate, boolean ignoreNulls, @Nullable org.apache.calcite.rex.RexNode filter, @Nullable com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> distinctKeys, com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> orderKeys, @Nullable String alias, com.google.common.collect.ImmutableList<org.apache.calcite.rex.RexNode> operands) Creates a call to an aggregate function with all applicable operands. -
count
Creates a call to theCOUNTaggregate function. -
count
Creates a call to theCOUNTaggregate function. -
count
public RelBuilder.AggCall count(boolean distinct, @Nullable String alias, org.apache.calcite.rex.RexNode... operands) Creates a call to theCOUNTaggregate function, optionally distinct and with an alias. -
count
public RelBuilder.AggCall count(boolean distinct, @Nullable String alias, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates a call to theCOUNTaggregate function, optionally distinct and with an alias. -
countStar
Creates a call to theCOUNT(*)aggregate function. -
sum
Creates a call to theSUMaggregate function. -
sum
public RelBuilder.AggCall sum(boolean distinct, @Nullable String alias, org.apache.calcite.rex.RexNode operand) Creates a call to theSUMaggregate function, optionally distinct and with an alias. -
avg
Creates a call to theAVGaggregate function. -
avg
public RelBuilder.AggCall avg(boolean distinct, @Nullable String alias, org.apache.calcite.rex.RexNode operand) Creates a call to theAVGaggregate function, optionally distinct and with an alias. -
min
Creates a call to theMINaggregate function. -
min
Creates a call to theMINaggregate function, optionally with an alias. -
max
Creates a call to theMAXaggregate function, optionally with an alias. -
max
Creates a call to theMAXaggregate function. -
patternField
public org.apache.calcite.rex.RexNode patternField(String alpha, org.apache.calcite.rel.type.RelDataType type, int i) Creates a reference to a given field of the pattern.- Parameters:
alpha- the pattern nametype- Type of fieldi- Ordinal of field- Returns:
- Reference to field of pattern
-
patternConcat
public org.apache.calcite.rex.RexNode patternConcat(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that concatenates patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternConcat
public org.apache.calcite.rex.RexNode patternConcat(org.apache.calcite.rex.RexNode... nodes) Creates a call that concatenates patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternAlter
public org.apache.calcite.rex.RexNode patternAlter(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that creates alternate patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternAlter
public org.apache.calcite.rex.RexNode patternAlter(org.apache.calcite.rex.RexNode... nodes) Creates a call that creates alternate patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternQuantify
public org.apache.calcite.rex.RexNode patternQuantify(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that creates quantify patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternQuantify
public org.apache.calcite.rex.RexNode patternQuantify(org.apache.calcite.rex.RexNode... nodes) Creates a call that creates quantify patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternPermute
public org.apache.calcite.rex.RexNode patternPermute(Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates a call that creates permute patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternPermute
public org.apache.calcite.rex.RexNode patternPermute(org.apache.calcite.rex.RexNode... nodes) Creates a call that creates permute patterns; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
patternExclude
public org.apache.calcite.rex.RexNode patternExclude(org.apache.calcite.rex.RexNode node) Creates a call that creates an exclude pattern; for use inmatch(org.apache.calcite.rex.RexNode, boolean, boolean, java.util.Map<java.lang.String, org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode, java.util.Map<java.lang.String, ? extends java.util.SortedSet<java.lang.String>>, boolean, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, java.lang.Iterable<? extends org.apache.calcite.rex.RexNode>, org.apache.calcite.rex.RexNode). -
scan
Creates aTableScanof the table with a given name.Throws if the table does not exist.
Returns this builder.
- Parameters:
tableNames- Name of table (can optionally be qualified)
-
scan
Creates aTableScanof the table with a given name.Throws if the table does not exist.
Returns this builder.
- Parameters:
tableNames- Name of table (can optionally be qualified)
-
snapshot
Creates aSnapshotof a given snapshot period.Returns this builder.
- Parameters:
period- Name of table (can optionally be qualified)
-
cursor
public org.apache.calcite.rex.RexNode cursor(int inputCount, int ordinal) Creates a RexCall to theCURSORfunction by ordinal.- Parameters:
inputCount- Number of inputsordinal- The reference to the relational input- Returns:
- RexCall to CURSOR function
-
functionScan
public RelBuilder functionScan(org.apache.calcite.sql.SqlOperator operator, int inputCount, org.apache.calcite.rex.RexNode... operands) Creates aTableFunctionScan. -
functionScan
public RelBuilder functionScan(org.apache.calcite.sql.SqlOperator operator, int inputCount, Iterable<? extends org.apache.calcite.rex.RexNode> operands) Creates aTableFunctionScan. -
filter
Creates aFilterof an array of predicates.The predicates are combined using AND, and optimized in a similar way to the
and(org.apache.calcite.rex.RexNode...)method. If the result is TRUE no filter is created. -
filter
Creates aFilterof a list of predicates.The predicates are combined using AND, and optimized in a similar way to the
and(org.apache.calcite.rex.RexNode...)method. If the result is TRUE no filter is created. -
filter
public RelBuilder filter(Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet, org.apache.calcite.rex.RexNode... predicates) Creates aFilterof a list of correlation variables and an array of predicates.The predicates are combined using AND, and optimized in a similar way to the
and(org.apache.calcite.rex.RexNode...)method. If the result is TRUE no filter is created. -
filter
public RelBuilder filter(Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet, Iterable<? extends org.apache.calcite.rex.RexNode> predicates) Creates aFilterof a list of correlation variables and a list of predicates.The predicates are combined using AND, and optimized in a similar way to the
and(org.apache.calcite.rex.RexNode...)method. If simplification is on and the result is TRUE, no filter is created. -
project
Creates aProjectof the given expressions. -
project
Creates aProjectof the given list of expressions.Infers names as would
project(Iterable, Iterable)if all suggested names were null.- Parameters:
nodes- Expressions
-
project
public RelBuilder project(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends @Nullable String> fieldNames) Creates aProjectof the given list of expressions and field names.- Parameters:
nodes- ExpressionsfieldNames- field names for expressions
-
project
public RelBuilder project(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends @Nullable String> fieldNames, boolean force) Creates aProjectof the given list of expressions, using the given names.Names are deduced as follows:
- If the length of
fieldNamesis greater than the index of the current entry innodes, and the entry infieldNamesis not null, uses it; otherwise - If an expression projects an input field, or is a cast an input field, uses the input field name; otherwise
- If an expression is a call to
SqlStdOperatorTable.AS(seealias(org.apache.calcite.rex.RexNode, java.lang.String)), removes the call but uses the intended alias.
After the field names have been inferred, makes the field names unique by appending numeric suffixes.
- Parameters:
nodes- ExpressionsfieldNames- Suggested field namesforce- create project even if it is identity
- If the length of
-
project
public RelBuilder project(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, Iterable<? extends @Nullable String> fieldNames, boolean force, Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet) The same withproject(Iterable, Iterable, boolean), with additional variablesSet param.- Parameters:
nodes- ExpressionsfieldNames- Suggested field namesforce- create project even if it is identityvariablesSet- Correlating variables that are set when reading a row from the input, and which may be referenced from the projection expressions
-
projectPlus
Creates aProjectof all original fields, plus the given expressions. -
projectPlus
Creates aProjectof all original fields, plus the given list of expressions. -
projectExcept
Creates aProjectof all original fields, except the given expressions.- Throws:
IllegalArgumentException- if the given expressions contain duplicates or there is an expression that does not match an existing field
-
projectExcept
Creates aProjectof all original fields, except the given list of expressions.- Throws:
IllegalArgumentException- if the given expressions contain duplicates or there is an expression that does not match an existing field
-
projectNamed
public RelBuilder projectNamed(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, @Nullable Iterable<? extends @Nullable String> fieldNames, boolean force) Creates aProjectof the given expressions and field names, and optionally optimizing.If
fieldNamesis null, or if a particular entry infieldNamesis null, derives field names from the input expressions.If
forceis false, and the input is aProject, and the expressions make the trivial projection ($0, $1, ...), modifies the input.- Parameters:
nodes- ExpressionsfieldNames- Suggested field names, or null to generateforce- Whether to create a renaming Project if the projections are trivial
-
projectNamed
public RelBuilder projectNamed(Iterable<? extends org.apache.calcite.rex.RexNode> nodes, @Nullable Iterable<? extends @Nullable String> fieldNames, boolean force, Iterable<org.apache.calcite.rel.core.CorrelationId> variablesSet) Creates aProjectof the given expressions and field names, and optionally optimizing.If
fieldNamesis null, or if a particular entry infieldNamesis null, derives field names from the input expressions.If
forceis false, and the input is aProject, and the expressions make the trivial projection ($0, $1, ...), modifies the input.- Parameters:
nodes- ExpressionsfieldNames- Suggested field names, or null to generateforce- Whether to create a renaming Project if the projections are trivialvariablesSet- Correlating variables that are set when reading a row from the input, and which may be referenced from the projection expressions
-
uncollect
Creates anUncollectwith given item aliases.- Parameters:
itemAliases- Operand item aliases, never nullwithOrdinality- IfwithOrdinality, the output contains an extraORDINALITYcolumn
-
rename
Ensures that the field names match those given.If all fields have the same name, adds nothing; if any fields do not have the same name, adds a
Project.Note that the names can be short-lived. Other
RelBuilderoperations make no guarantees about the field names of the rows they produce.- Parameters:
fieldNames- List of desired field names; may contain null values or have fewer fields than the current row type
-
distinct
Creates anAggregatethat makes the relational expression distinct on all fields. -
aggregate
Creates anAggregatewith an array of calls. -
aggregate
public RelBuilder aggregate(RelBuilder.GroupKey groupKey, List<org.apache.calcite.rel.core.AggregateCall> aggregateCalls) Creates anAggregatewith an array ofAggregateCalls. -
aggregate
Creates anAggregatewith multiple calls. -
union
Creates aUnionof the two most recent relational expressions on the stack.- Parameters:
all- Whether to create UNION ALL
-
union
Creates aUnionof thenmost recent relational expressions on the stack.- Parameters:
all- Whether to create UNION ALLn- Number of inputs to the UNION operator
-
intersect
Creates anIntersectof the two most recent relational expressions on the stack.- Parameters:
all- Whether to create INTERSECT ALL
-
intersect
Creates anIntersectof thenmost recent relational expressions on the stack.- Parameters:
all- Whether to create INTERSECT ALLn- Number of inputs to the INTERSECT operator
-
minus
Creates aMinusof the two most recent relational expressions on the stack.- Parameters:
all- Whether to create EXCEPT ALL
-
minus
Creates aMinusof thenmost recent relational expressions on the stack.- Parameters:
all- Whether to create EXCEPT ALL
-
transientScan
Creates aTableScanon aTransientTablewith the given name, using as type the top of the stack's type.- Parameters:
tableName- table name
-
transientScan
Creates aTableScanon aTransientTablewith the given name and type.- Parameters:
tableName- table namerowType- row type of the table
-
repeatUnion
Creates aRepeatUnionassociated to aTransientTablewithout a maximum number of iterations, i.e. repeatUnion(tableName, all, -1).- Parameters:
tableName- name of theTransientTableassociated to theRepeatUnionall- whether duplicates will be considered or not
-
repeatUnion
Creates aRepeatUnionassociated to aTransientTableof the two most recent relational expressions on the stack.Warning: if these relational expressions are not correctly defined, this operation might lead to an infinite loop.
The generated
RepeatUnionoperates as follows:- Evaluate its left term once, propagating the results into the
TransientTable; - Evaluate its right term (which may contain a
TableScanon theTransientTable) over and over until it produces no more results (or until an optional maximum number of iterations is reached). On each iteration, the results are propagated into theTransientTable, overwriting the results from the previous one.
- Parameters:
tableName- Name of theTransientTableassociated to theRepeatUnionall- Whether duplicates are considerediterationLimit- Maximum number of iterations; negative value means no limit
- Evaluate its left term once, propagating the results into the
-
join
public RelBuilder join(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rex.RexNode condition0, org.apache.calcite.rex.RexNode... conditions) Creates aJoinwith an array of conditions. -
join
public RelBuilder join(org.apache.calcite.rel.core.JoinRelType joinType, Iterable<? extends org.apache.calcite.rex.RexNode> conditions) Creates aJoinwith multiple conditions. -
join
public RelBuilder join(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rex.RexNode condition) Creates aJoinwith one condition. -
join
public RelBuilder join(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rex.RexNode condition, Set<org.apache.calcite.rel.core.CorrelationId> variablesSet) Creates aJoinwith correlating variables. -
correlate
public RelBuilder correlate(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rel.core.CorrelationId correlationId, org.apache.calcite.rex.RexNode... requiredFields) Creates aCorrelatewith aCorrelationIdand an array of fields that are used by correlation. -
correlate
public RelBuilder correlate(org.apache.calcite.rel.core.JoinRelType joinType, org.apache.calcite.rel.core.CorrelationId correlationId, Iterable<? extends org.apache.calcite.rex.RexNode> requiredFields) Creates aCorrelatewith aCorrelationIdand a list of fields that are used by correlation. -
join
Creates aJoinusing USING syntax.For each of the field names, both left and right inputs must have a field of that name. Constructs a join condition that the left and right fields are equal.
- Parameters:
joinType- Join typefieldNames- Field names
-
semiJoin
Creates aJoinwithJoinRelType.SEMI.A semi-join is a form of join that combines two relational expressions according to some condition, and outputs only rows from the left input for which at least one row from the right input matches. It only outputs columns from the left input, and ignores duplicates on the right.
For example,
EMP semi-join DEPTfinds allEMPrecords that do not have a correspondingDEPTrecord, similar to the following SQL:SELECT * FROM EMP WHERE EXISTS (SELECT 1 FROM DEPT WHERE DEPT.DEPTNO = EMP.DEPTNO) -
semiJoin
Creates aJoinwithJoinRelType.SEMI.- See Also:
-
antiJoin
Creates an anti-join.An anti-join is a form of join that combines two relational expressions according to some condition, but outputs only rows from the left input for which no rows from the right input match.
For example,
EMP anti-join DEPTfinds allEMPrecords that do not have a correspondingDEPTrecord, similar to the following SQL:SELECT * FROM EMP WHERE NOT EXISTS (SELECT 1 FROM DEPT WHERE DEPT.DEPTNO = EMP.DEPTNO) -
antiJoin
Creates an anti-join.- See Also:
-
as
Assigns a table alias to the top entry on the stack. -
values
Creates aValues.The
valuesarray must have the same number of entries asfieldNames, or an integer multiple if you wish to create multiple rows.If there are zero rows, or if all values of a any column are null, this method cannot deduce the type of columns. For these cases, call
values(Iterable, RelDataType).- Parameters:
fieldNames- Field namesvalues- Values
-
empty
Creates a relational expression that reads from an input and throws all of the rows away.Note that this method always pops one relational expression from the stack.
values, in contrast, does not pop any relational expressions, and always produces a leaf.The default implementation creates a
Valueswith the same specified row type and aliases as the input, and ignores the input entirely. But schema-on-query systems such as Drill might override this method to create a relation expression that retains the input, just to read its schema. -
values
Creates aValueswith a specified row type.This method can handle cases that
values(String[], Object...)cannot, such as all values of a column being null, or there being zero rows.- Parameters:
rowType- Row typecolumnValues- Values
-
values
public RelBuilder values(Iterable<? extends List<org.apache.calcite.rex.RexLiteral>> tupleList, org.apache.calcite.rel.type.RelDataType rowType) Creates aValueswith a specified row type.This method can handle cases that
values(String[], Object...)cannot, such as all values of a column being null, or there being zero rows.- Parameters:
tupleList- Tuple listrowType- Row type
-
values
Creates aValueswith a specified row type and zero rows.- Parameters:
rowType- Row type
-
limit
Creates a limit without a sort. -
exchange
Creates an Exchange by distribution. -
sortExchange
public RelBuilder sortExchange(org.apache.calcite.rel.RelDistribution distribution, org.apache.calcite.rel.RelCollation collation) Creates a SortExchange by distribution and collation. -
sort
Creates aSortby field ordinals.Negative fields mean descending: -1 means field(0) descending, -2 means field(1) descending, etc.
-
sort
Creates aSortby expressions. -
sort
Creates aSortby expressions. -
sortLimit
Creates aSortby expressions, with limit and offset. -
sort
Creates aSortby specifying collations. -
sortLimit
public RelBuilder sortLimit(int offset, int fetch, Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates aSortby a list of expressions, with limit and offset.- Parameters:
offset- Number of rows to skip; non-positive means don't skip anyfetch- Maximum number of rows to fetch; negative means no limitnodes- Sort expressions
-
sortLimit
public RelBuilder sortLimit(@Nullable org.apache.calcite.rex.RexNode offsetNode, @Nullable org.apache.calcite.rex.RexNode fetchNode, Iterable<? extends org.apache.calcite.rex.RexNode> nodes) Creates aSortby a list of expressions, with limitNode and offsetNode.- Parameters:
offsetNode- RexLiteral means number of rows to skip is deterministic, RexDynamicParam means number of rows to skip is dynamic.fetchNode- RexLiteral means maximum number of rows to fetch is deterministic, RexDynamicParam mean maximum number is dynamic.nodes- Sort expressions
-
convert
Creates a projection that converts the current relational expression's output to a desired row type.The desired row type and the row type to be converted must have the same number of fields.
- Parameters:
castRowType- row type after castrename- if true, use field names from castRowType; if false, preserve field names from rel
-
permute
-
match
public RelBuilder match(org.apache.calcite.rex.RexNode pattern, boolean strictStart, boolean strictEnd, Map<String, org.apache.calcite.rex.RexNode> patternDefinitions, Iterable<? extends org.apache.calcite.rex.RexNode> measureList, org.apache.calcite.rex.RexNode after, Map<String, ? extends SortedSet<String>> subsets, boolean allRows, Iterable<? extends org.apache.calcite.rex.RexNode> partitionKeys, Iterable<? extends org.apache.calcite.rex.RexNode> orderKeys, org.apache.calcite.rex.RexNode interval) Creates aMatch. -
pivot
public RelBuilder pivot(RelBuilder.GroupKey groupKey, Iterable<? extends RelBuilder.AggCall> aggCalls, Iterable<? extends org.apache.calcite.rex.RexNode> axes, Iterable<? extends Map.Entry<String, ? extends Iterable<? extends org.apache.calcite.rex.RexNode>>> values) Creates a Pivot.To achieve the same effect as the SQL
SELECT * FROM (SELECT mgr, deptno, job, sal FROM emp) PIVOT (SUM(sal) AS ss, COUNT(*) AS c FOR (job, deptno) IN (('CLERK', 10) AS c10, ('MANAGER', 20) AS m20))use the builder as follows:
RelBuilder b; b.scan("EMP"); final RelBuilder.GroupKey groupKey = b.groupKey("MGR"); final List<RelBuilder.AggCall> aggCalls = Arrays.asList(b.sum(b.field("SAL")).as("SS"), b.count().as("C")); final List<RexNode> axes = Arrays.asList(b.field("JOB"), b.field("DEPTNO")); final ImmutableMap.Builder<String, List<RexNode>> valueMap = ImmutableMap.builder(); valueMap.put("C10", Arrays.asList(b.literal("CLERK"), b.literal(10))); valueMap.put("M20", Arrays.asList(b.literal("MANAGER"), b.literal(20))); b.pivot(groupKey, aggCalls, axes, valueMap.build().entrySet());Note that the SQL uses a sub-query to project away columns (e.g.
HIREDATE) that it does not reference, so that they do not appear in theGROUP BY. You do not need to do that in this API, because thegroupKeyparameter specifies the keys.Pivot is implemented by desugaring. The above example becomes the following:
SELECT mgr, SUM(sal) FILTER (WHERE job = 'CLERK' AND deptno = 10) AS c10_ss, COUNT(*) FILTER (WHERE job = 'CLERK' AND deptno = 10) AS c10_c, SUM(sal) FILTER (WHERE job = 'MANAGER' AND deptno = 20) AS m20_ss, COUNT(*) FILTER (WHERE job = 'MANAGER' AND deptno = 20) AS m20_c FROM emp GROUP BY mgr- Parameters:
groupKey- Key columnsaggCalls- Aggregate expressions to compute for each valueaxes- Columns to pivotvalues- Values to pivot, and the alias for each column group- Returns:
- this RelBuilder
-
unpivot
public RelBuilder unpivot(boolean includeNulls, Iterable<String> measureNames, Iterable<String> axisNames, Iterable<? extends Map.Entry<? extends List<? extends org.apache.calcite.rex.RexLiteral>, ? extends List<? extends org.apache.calcite.rex.RexNode>>> axisMap) Creates an Unpivot.To achieve the same effect as the SQL
SELECT * FROM (SELECT deptno, job, sal, comm FROM emp) UNPIVOT INCLUDE NULLS (remuneration FOR remuneration_type IN (comm AS 'commission', sal AS 'salary'))use the builder as follows:
RelBuilder b; b.scan("EMP"); final List<String> measureNames = Arrays.asList("REMUNERATION"); final List<String> axisNames = Arrays.asList("REMUNERATION_TYPE"); final Map<List<RexLiteral>, List<RexNode>> axisMap = ImmutableMap.<List<RexLiteral>, List<RexNode>>builder() .put(Arrays.asList(b.literal("commission")), Arrays.asList(b.field("COMM"))) .put(Arrays.asList(b.literal("salary")), Arrays.asList(b.field("SAL"))) .build(); b.unpivot(false, measureNames, axisNames, axisMap);The query generates two columns:
remuneration_type(an axis column) andremuneration(a measure column). Axis columns contain values to indicate the source of the row (in this case,'salary'if the row came from thesalcolumn, and'commission'if the row came from thecommcolumn).- Parameters:
includeNulls- Whether to include NULL values in the outputmeasureNames- Names of columns to be generated to hold pivoted measuresaxisNames- Names of columns to be generated to hold qualifying valuesaxisMap- Mapping from the columns that hold measures to the values that the axis columns will hold in the generated rows- Returns:
- This RelBuilder
-
hints
Attaches an array of hints to the stack top relational expression.The redundant hints would be eliminated.
- Parameters:
hints- Hints- Throws:
AssertionError- if the top relational expression does not implementHintable
-
hints
Attaches multiple hints to the stack top relational expression.The redundant hints would be eliminated.
- Parameters:
hints- Hints- Throws:
AssertionError- if the top relational expression does not implementHintable
-
clear
public void clear()Clears the stack.The builder's state is now the same as when it was created.
-
groupKey(Iterable, Iterable), which has the same behavior as calling this method withindicator = false.