Package org.apache.calcite.rex
Provides a language for representing row-expressions.
Life-cycle
A SqlToRelConverter
converts a SQL
parse tree consisting of SqlNode
objects into
a relational expression (RelNode
). Several
kinds of nodes in this tree have row expressions
(RexNode
).
After the relational expression has been optimized, a
JavaRelImplementor
converts it
into to a plan. If the plan is a Java parse tree, row-expressions are
translated into equivalent Java expressions.
Expressions
Every row-expression has a type. (Compare with
SqlNode
, which is created before validation,
and therefore types may not be available.)
Every node in the parse tree is a RexNode
.
Sub-types are:
RexLiteral
represents a boolean, numeric, string, or date constant, or the valueNULL
.RexVariable
represents a leaf of the tree. It has sub-types:RexCorrelVariable
is a correlating variable for nested-loop joinsRexInputRef
refers to a field of an input relational expressionRexCall
is a call to an operator or function. By means of special operators, we can use this construct to represent virtually every non-leaf node in the tree.RexRangeRef
refers to a collection of contiguous fields from an input relational expression. It usually exists only during translation.
Expressions are generally
created using a RexBuilder
factory.
Related packages
org.apache.calcite.sql
SQL object modelorg.apache.calcite.plan
Core classes, includingRelDataType
andRelDataTypeFactory
.
-
Interface Summary Interface Description RexAction ARexAction
is called when aRexPattern
finds a match.RexBiVisitor<R,P> Visitor pattern for traversing a tree ofRexNode
objects and passing a payload to each.RexExecutor Can reduce expressions, writing a literal for each into a list.RexPattern ARexPattern
represents an expression with holes in it.RexSimplify.Predicate Marker interface for predicates (expressions that evaluate to BOOLEAN).RexSqlConvertlet RexSqlConvertletTable Collection ofRexSqlConvertlet
s.RexToSqlNodeConverter RexVisitor<R> Visitor pattern for traversing a tree ofRexNode
objects. -
Class Summary Class Description LogicVisitor Visitor pattern for traversing a tree ofRexNode
objects.RexAnalyzer Analyzes an expression, figures out what are the unbound variables, assigns a variety of values to each unbound variable, and evaluates the expression.RexAnalyzer.VariableCollector Collects the variables (or other bindable sites) in an expression, and counts features (such as CAST) thatRexInterpreter
cannot handle.RexBuilder Factory for row expressions.RexCall An expression formed by a call to an operator with zero or more expressions as operands.RexCallBinding RexCallBinding
implementsSqlOperatorBinding
by referring to an underlying collection ofRexNode
operands.RexCallBinding.RexCastCallBinding To be compatible withSqlCall
, CAST needs to pretend that it has two arguments, the second of which is the target type.RexChecker Visitor which checks the validity of aRexNode
expression.RexCopier Shuttle which creates a deep copy of a Rex expression.RexCorrelVariable Reference to the current row of a correlating relational expression.RexDynamicParam Dynamic parameter reference in a row-expression.RexExecutable Result of compiling code generated from aRexNode
expression.RexExecutorImpl Evaluates aRexNode
expression.RexExecutorImpl.DataContextInputGetter Implementation ofRexToLixTranslator.InputGetter
that reads the values of input fields by calling
.DataContext.get(java.lang.String)
("inputRecord")RexFieldAccess Access to a field of a row-expression.RexFieldCollation Expression combined with sort flags (DESCENDING, NULLS LAST).RexFieldCollation.Initializer Helper, used during initialization, that builds a canonizing map from sets ofSqlKind
to immutable sets ofSqlKind
.RexInputRef Variable which references a field of an input relational expression.RexInterpreter EvaluatesRexNode
expressions.RexLiteral Constant value in a row-expression.RexLocalRef Local variable.RexMultisetUtil Utility class for various methods related to multisets.RexMultisetUtil.RexCallMultisetOperatorCounter A RexShuttle that traverse all RexNode and counts total number of RexCalls traversed and number of multiset calls traversed.RexNode Row expression.RexOver Call to an aggregate function over a window.RexOver.Finder RexPatternFieldRef Variable which references a field of an input relational expressionRexPermutationShuttle Visitor which replacesRexLocalRef
objects after the expressions in aRexProgram
have been reordered.RexPermuteInputsShuttle Shuttle which applies a permutation to its input fields.RexProgram A collection of expressions which read inputs, compute output expressions, and optionally use a condition to filter rows.RexProgram.Checker Visitor which walks over a program and checks validity.RexProgram.ExpansionShuttle A RexShuttle used in the implementation ofRexProgram.expandLocalRef(org.apache.calcite.rex.RexLocalRef)
.RexProgramBuilder Workspace for constructing aRexProgram
.RexRangeRef Reference to a range of columns.RexShuttle Passes over a row-expression, calling a handler method for each node, appropriate to the type of the node.RexSimplify Context required to simplify a row-expression.RexSimplify.CaseBranch Object to describe a Case branchRexSimplify.Comparison Comparison between aRexInputRef
orRexFieldAccess
and a literal.RexSimplify.IsPredicate Represents an IS Predicate.RexSlot Abstract base class forRexInputRef
andRexLocalRef
.RexSlot.SelfPopulatingList Thread-safe list that populates itself if you make a reference beyond the end of the list.RexSqlReflectiveConvertletTable Implementation ofRexSqlConvertletTable
.RexSqlStandardConvertletTable Standard implementation ofRexSqlConvertletTable
.RexSubQuery Scalar expression that represents an IN, EXISTS or scalar sub-query.RexTableInputRef Variable which references a column of a table occurrence in a relational plan.RexTableInputRef.RelTableRef Identifies uniquely a table by its qualified name and its entity number (occurrence)RexToSqlNodeConverterImpl Standard implementation ofRexToSqlNodeConverter
.RexTransformer Takes a tree ofRexNode
objects and transforms it into another in one sense equivalent tree.RexUtil Utility methods concerning row-expressions.RexUtil.CnfHelper RexUtil.ConstantFinder Walks over an expression and determines whether it is constant.RexUtil.CorrelationFinder Visitor that throwsUtil.FoundOne
if applied to an expression that contains aRexCorrelVariable
.RexUtil.DnfHelper RexUtil.ExpressionNormalizer Walks over expressions and builds a bank of common sub-expressions.RexUtil.ExprSimplifier Deprecated. RexUtil.FieldAccessFinder Visitor which builds a bitmap of the inputs used by an expression.RexUtil.FixNullabilityShuttle Shuttle that fixes up an expression to match changes in nullability of input fields.RexUtil.ForwardRefFinder Walks over an expression and throws an exception if it finds anRexInputRef
with an ordinal beyond the number of fields in the input row type, or aRexLocalRef
with ordinal greater than that set usingRexUtil.ForwardRefFinder.setLimit(int)
.RexUtil.RexShiftShuttle Shuttle that addsoffset
to eachRexInputRef
in an expression.RexUtil.SubQueryFinder Visitor that throwsUtil.FoundOne
if applied to an expression that contains aRexSubQuery
.RexVariable A row-expression which references a field.RexVisitorImpl<R> Default implementation ofRexVisitor
, which visits each node but does nothing while it's there.RexWindow Specification of the window of rows over which aRexOver
windowed aggregate is evaluated.RexWindowBound Abstracts "XX PRECEDING/FOLLOWING" and "CURRENT ROW" bounds for windowed aggregates.RexWindowBound.RexWindowBoundBounded Implements XX PRECEDING/FOLLOWING bound where XX is not UNBOUNDED.RexWindowBound.RexWindowBoundCurrentRow Implements CURRENT ROW bound.RexWindowBound.RexWindowBoundUnbounded Implements UNBOUNDED PRECEDING/FOLLOWING bound. -
Enum Summary Enum Description RexInterpreter.Truthy An enum that wraps boolean and unknown values and makes them comparable.RexSimplify.SafeRexVisitor Decides whether it is safe to flatten the given case part into AND/ORsRexUnknownAs Policy for whether a simplified expression may instead return another value. -
Exception Summary Exception Description RexOver.OverFound Exception thrown when an OVER is found.RexUtil.CnfHelper.OverflowError Exception to catch when we pass the limit.RexUtil.ExpressionNormalizer.SubExprExistsException Thrown if there is a sub-expression.RexUtil.ForwardRefFinder.IllegalForwardRefException Thrown to abort a visit when we find an illegal forward reference.