Provides a language for representing row-expressions.

Revision | $Id: //open/dev/farrago/src/org/eigenbase/rex/package.html#7 $
Copyright | Copyright (C) 2005-2009 The Eigenbase Project Copyright (C) 2003-2009 SQLstream, Inc. Copyright (C) 2005-2009 LucidEra, Inc.
Author | Julian Hyde

## Life-cycle

A {@link org.eigenbase.sql2rel.SqlToRelConverter} converts a SQL parse tree consisting of {@link org.eigenbase.sql.SqlNode} objects into a relational expression ({@link org.eigenbase.rel.RelNode}). Several kinds of nodes in this tree have row expressions ({@link org.eigenbase.rex.RexNode}).

After the relational expression has been optimized, a {@link org.eigenbase.oj.rel.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 {@link org.eigenbase.sql.SqlNode}, which is created before validation, and therefore types may not be available.)

Every node in the parse tree is a {@link org.eigenbase.rex.RexNode}. Sub-types are:

- {@link org.eigenbase.rex.RexLiteral} represents a boolean, numeric, string, or date constant, or the value `NULL`.
- {@link org.eigenbase.rex.RexVariable} represents a leaf of the tree. It has sub-types:
  - {@link org.eigenbase.rex.RexCorrelVariable} is a correlating variable for nested-loop joins
  - {@link org.eigenbase.rex.RexInputRef} refers to a field of an input relational expression
  - {@link org.eigenbase.rex.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.
  - {@link org.eigenbase.rex.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 {@link org.eigenbase.rex.RexBuilder} factory. If Java expressions are to be converted, you can use a derived class, {@link org.eigenbase.oj.util.JavaRexBuilder}.

  ## Related packages

  - {@link org.eigenbase.sql} SQL object model
  - {@link org.eigenbase.relopt} Core classes, including {@link org.eigenbase.reltype.RelDataType} and {@link org.eigenbase.reltype.RelDataTypeFactory}.