Package org.apache.calcite.rex

@DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class,locations=FIELD) @DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class,locations=PARAMETER) @DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class,locations=RETURN) package org.apache.calcite.rex
Provides a language for representing row-expressions.


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.


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 value NULL.
  • RexVariable represents a leaf of the tree. It has sub-types:
    • RexCorrelVariable is a correlating variable for nested-loop joins
    • RexInputRef refers to a field of an input relational expression
    • RexCall 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