|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.rex.RexBuilder
public class RexBuilder
Factory for row expressions.
Some common literal values (NULL, TRUE, FALSE, 0, 1, '') are cached.
Field Summary | |
---|---|
private RexLiteral |
booleanFalse
|
private RexLiteral |
booleanTrue
|
private RexLiteral |
charEmpty
|
private RexLiteral |
constantNull
|
private SqlStdOperatorTable |
opTab
|
protected RelDataTypeFactory |
typeFactory
|
Constructor Summary | |
---|---|
RexBuilder(RelDataTypeFactory typeFactory)
Creates a RexBuilder. |
Method Summary | |
---|---|
RexNode |
addAggCall(AggregateCall aggCall,
int groupCount,
List<AggregateCall> aggCalls,
Map<AggregateCall,RexNode> aggCallMapping)
Creates a reference to an aggregate call, checking for repeated calls. |
RexLiteral |
constantNull()
Creates a constant for the SQL NULL value. |
RexNode |
copy(RexNode expr)
Creates a copy of an expression, which may have been created using a different RexBuilder and/or RelDataTypeFactory , using this
RexBuilder. |
RelDataType |
deriveReturnType(SqlOperator op,
RelDataTypeFactory typeFactory,
RexNode[] exprs)
Derives the return type of a call to an operator. |
SqlStdOperatorTable |
getOpTab()
Returns this RexBuilder's operator table |
RelDataTypeFactory |
getTypeFactory()
Returns this RexBuilder's type factory |
RexNode |
makeAbstractCast(RelDataType type,
RexNode exp)
Creates a call to the CAST operator. |
RexLiteral |
makeApproxLiteral(BigDecimal bd)
Creates a double-precision literal. |
RexLiteral |
makeApproxLiteral(BigDecimal bd,
RelDataType type)
Creates an approximate numeric literal (double or float). |
RexLiteral |
makeBigintLiteral(BigDecimal bd)
Creates a BIGINT literal. |
RexLiteral |
makeBinaryLiteral(byte[] byteArray)
Creates a byte array literal. |
RexNode |
makeCall(RelDataType returnType,
SqlOperator op,
RexNode... exprs)
Creates a call with an array of arguments and a predetermined type. |
RexNode |
makeCall(SqlOperator op,
List<? extends RexNode> exprList)
Creates a call with a list of arguments. |
RexNode |
makeCall(SqlOperator op,
RexNode... exprs)
Creates a call with an array of arguments. |
RexNode |
makeCast(RelDataType type,
RexNode exp)
Creates a call to the CAST operator, expanding if possible. |
RexLiteral |
makeCharLiteral(NlsString str)
Creates a character string literal from an NlsString . |
RexNode |
makeCorrel(RelDataType type,
String name)
Creates an expression referencing a correlation variable. |
RexLiteral |
makeDateLiteral(Calendar date)
Creates a Date literal. |
RexDynamicParam |
makeDynamicParam(RelDataType type,
int index)
Creates a reference to a dynamic parameter |
RexLiteral |
makeExactLiteral(BigDecimal bd)
Creates a numeric literal. |
RexLiteral |
makeExactLiteral(BigDecimal bd,
RelDataType type)
Creates a numeric literal. |
RexNode |
makeFieldAccess(RexNode expr,
int i)
Creates an expression accessing a field with a given ordinal from a record. |
RexNode |
makeFieldAccess(RexNode expr,
String fieldName)
Creates an expression accessing a given named field from a record. |
private RexNode |
makeFieldAccessInternal(RexNode expr,
RelDataTypeField field)
Creates an expression accessing a given field from a record. |
RexLiteral |
makeFlag(Object flag)
Creates a literal representing a flag. |
RexNode |
makeInputRef(RelDataType type,
int i)
Creates a referenence to a given field of the input record. |
RexLiteral |
makeIntervalLiteral(long l,
SqlIntervalQualifier intervalQualifier)
Creates an interval literal. |
RexLiteral |
makeIntervalLiteral(SqlIntervalQualifier intervalQualifier)
Creates an interval literal. |
RexLiteral |
makeLiteral(boolean b)
Creates a boolean literal. |
protected RexLiteral |
makeLiteral(Comparable o,
RelDataType type,
SqlTypeName typeName)
Internal method to create a call to a literal. |
RexLiteral |
makeLiteral(String s)
Creates a character string literal. |
RexNode |
makeNewInvocation(RelDataType type,
RexNode[] exprs)
Creates an invocation of the NEW operator. |
RexNode |
makeNotNullCast(RexNode expr)
Makes an expression which converts a value of type T to a value of type T NOT NULL, or throws if the value is NULL. |
RexNode |
makeNullLiteral(SqlTypeName typeName)
Creates a literal whose value is NULL, with a particular type. |
RexNode |
makeNullLiteral(SqlTypeName typeName,
int precision)
Creates an expression corresponding to a null literal, cast to a specific type and precision |
RexNode |
makeOver(RelDataType type,
SqlAggFunction operator,
RexNode[] exprs,
RexNode[] partitionKeys,
RexNode[] orderKeys,
SqlNode lowerBound,
SqlNode upperBound,
boolean physical,
boolean allowPartial,
boolean nullWhenCountZero)
Creates a call to a windowed agg. |
protected RexLiteral |
makePreciseStringLiteral(String s)
Creates a character string literal with type CHAR and default charset and collation. |
RexNode |
makeRangeReference(RelDataType rowType)
Creates a reference to all the fields in the row. |
RexNode |
makeRangeReference(RelDataType type,
int offset,
boolean nullable)
Creates a reference to all the fields in the row. |
RexNode |
makeReinterpretCast(RelDataType type,
RexNode exp,
RexNode checkOverflow)
Makes a reinterpret cast. |
RexLiteral |
makeTimeLiteral(Calendar time,
int precision)
Creates a Time literal. |
RexLiteral |
makeTimestampLiteral(Calendar timestamp,
int precision)
Creates a Timestamp literal. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final RelDataTypeFactory typeFactory
private final RexLiteral booleanTrue
private final RexLiteral booleanFalse
private final RexLiteral charEmpty
private final RexLiteral constantNull
private final SqlStdOperatorTable opTab
Constructor Detail |
---|
public RexBuilder(RelDataTypeFactory typeFactory)
typeFactory
- Type factoryMethod Detail |
---|
public RelDataTypeFactory getTypeFactory()
public SqlStdOperatorTable getOpTab()
public RexNode makeFieldAccess(RexNode expr, String fieldName)
expr
- Expression yielding a recordfieldName
- Name of field in record
public RexNode makeFieldAccess(RexNode expr, int i)
expr
- Expression yielding a recordi
- Ordinal of field
private RexNode makeFieldAccessInternal(RexNode expr, RelDataTypeField field)
expr
- Expression yielding a recordfield
- Field
public RexNode makeCall(RelDataType returnType, SqlOperator op, RexNode... exprs)
public RexNode makeCall(SqlOperator op, RexNode... exprs)
This is the fundamental method called by all of the other
makeCall
methods. If you derive a class from RexBuilder
,
this is the only method you need to override.
public final RexNode makeCall(SqlOperator op, List<? extends RexNode> exprList)
Equivalent to makeCall(op, exprList.toArray(new
RexNode[exprList.size()]))
.
public RelDataType deriveReturnType(SqlOperator op, RelDataTypeFactory typeFactory, RexNode[] exprs)
op
- the operator being calledtypeFactory
- factory for return typeexprs
- actual operands
public RexNode addAggCall(AggregateCall aggCall, int groupCount, List<AggregateCall> aggCalls, Map<AggregateCall,RexNode> aggCallMapping)
public RexNode makeOver(RelDataType type, SqlAggFunction operator, RexNode[] exprs, RexNode[] partitionKeys, RexNode[] orderKeys, SqlNode lowerBound, SqlNode upperBound, boolean physical, boolean allowPartial, boolean nullWhenCountZero)
public RexLiteral constantNull()
NULL
value.
public RexNode makeCorrel(RelDataType type, String name)
type
- Type of variablename
- Name of variable
public RexNode makeNewInvocation(RelDataType type, RexNode[] exprs)
type
- Type to be instantiatedexprs
- Arguments to NEW operator
public RexNode makeCast(RelDataType type, RexNode exp)
type
- Type to cast toexp
- Expression being cast
public RexNode makeAbstractCast(RelDataType type, RexNode exp)
type
- Type to cast toexp
- Expression being cast
public RexNode makeReinterpretCast(RelDataType type, RexNode exp, RexNode checkOverflow)
type
- type returned by the castexp
- expression to be castedcheckOverflow
- whether an overflow check is required
public RexNode makeNotNullCast(RexNode expr)
public RexNode makeRangeReference(RelDataType rowType)
rowType
- Type of the input row.public RexNode makeRangeReference(RelDataType type, int offset, boolean nullable)
For example, if the input row has type T{f0,f1,f2,f3,f4}
then makeRangeReference(T{f0,f1,f2,f3,f4}, S{f3,f4}, 3)
is
an expression which yields the last 2 fields.
type
- Type of the resulting range record.offset
- Index of first field.nullable
- Whether the record is nullable.public RexNode makeInputRef(RelDataType type, int i)
type
- Type of fieldi
- Ordinal of field
public RexLiteral makeFlag(Object flag)
flag
- Flag value; must be either a Enum14.Value
or a Enum
, and hence a Comparable
.protected RexLiteral makeLiteral(Comparable o, RelDataType type, SqlTypeName typeName)
makeDateLiteral(Calendar)
, makeLiteral(boolean)
, makeLiteral(String)
.
o
- Value of literal, must be appropriate for the typetype
- Type of literaltypeName
- SQL type of literal
public RexLiteral makeLiteral(boolean b)
public RexLiteral makeExactLiteral(BigDecimal bd)
public RexLiteral makeBigintLiteral(BigDecimal bd)
public RexLiteral makeExactLiteral(BigDecimal bd, RelDataType type)
public RexLiteral makeBinaryLiteral(byte[] byteArray)
public RexLiteral makeApproxLiteral(BigDecimal bd)
public RexLiteral makeApproxLiteral(BigDecimal bd, RelDataType type)
bd
- literal valuetype
- approximate numeric type
public RexLiteral makeLiteral(String s)
protected RexLiteral makePreciseStringLiteral(String s)
s
- String value
public RexLiteral makeCharLiteral(NlsString str)
NlsString
.
If the string's charset and collation are not set, uses the system defaults.
public RexLiteral makeDateLiteral(Calendar date)
public RexLiteral makeTimeLiteral(Calendar time, int precision)
public RexLiteral makeTimestampLiteral(Calendar timestamp, int precision)
public RexLiteral makeIntervalLiteral(SqlIntervalQualifier intervalQualifier)
public RexLiteral makeIntervalLiteral(long l, SqlIntervalQualifier intervalQualifier)
public RexDynamicParam makeDynamicParam(RelDataType type, int index)
type
- Type of dynamic parameterindex
- Index of dynamic parameter
public RexNode makeNullLiteral(SqlTypeName typeName, int precision)
typeName
- name of the type that the null will be cast toprecision
- precision of the type
public RexNode makeNullLiteral(SqlTypeName typeName)
The typing is necessary because RexNodes are strictly typed. For
example, in the Rex world the NULL
parameter to
SUBSTRING(NULL FROM 2 FOR 4)
must have a valid VARCHAR type so
that the result type can be determined.
typeName
- Type to cast NULL to
public RexNode copy(RexNode expr)
RelDataTypeFactory
, using this
RexBuilder.
expr
- Expression
RelDataTypeFactory.copyType(RelDataType)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |