public class RexToLixTranslator extends Object
REX expressions to
linq4j expressions.| Modifier and Type | Class and Description |
|---|---|
static interface |
RexToLixTranslator.InputGetter
Translates a field of an input to an expression.
|
static class |
RexToLixTranslator.InputGetterImpl
Implementation of
RexToLixTranslator.InputGetter that calls
PhysType.fieldReference(org.apache.calcite.linq4j.tree.Expression, int). |
| Modifier and Type | Field and Description |
|---|---|
static Map<Method,SqlOperator> |
JAVA_TO_SQL_METHOD_MAP |
| Modifier and Type | Method and Description |
|---|---|
static Expression |
convert(Expression operand,
Type toType) |
RexNode |
deref(RexNode expr)
Dereferences an expression if it is a
RexLocalRef. |
static RexToLixTranslator |
forAggregation(JavaTypeFactory typeFactory,
BlockBuilder list,
RexToLixTranslator.InputGetter inputGetter)
Creates a translator for translating aggregate functions.
|
Expression |
getRoot() |
protected Boolean |
isKnownNullable(RexNode node)
Walks parent translator chain and verifies if the expression is nullable.
|
boolean |
isNullable(RexNode e)
Returns whether an expression is nullable.
|
RelDataType |
nullifyType(RelDataType type,
boolean nullable) |
RexToLixTranslator |
setBlock(BlockBuilder block) |
RexToLixTranslator |
setCorrelates(Function1<String,RexToLixTranslator.InputGetter> correlates) |
RexToLixTranslator |
setNullable(Map<? extends RexNode,Boolean> nullable)
Creates a read-only copy of this translator that records that a given
expression is nullable.
|
RexToLixTranslator |
setNullable(RexNode e,
boolean nullable)
Creates a read-only copy of this translator that records that a given
expression is nullable.
|
static Expression |
translateCondition(RexProgram program,
JavaTypeFactory typeFactory,
BlockBuilder list,
RexToLixTranslator.InputGetter inputGetter,
Function1<String,RexToLixTranslator.InputGetter> correlates) |
Expression |
translateConstructor(List<RexNode> operandList,
SqlKind kind) |
List<Expression> |
translateList(List<? extends RexNode> operandList)
Translates the list of
RexNode, using the default output types. |
List<Expression> |
translateList(List<? extends RexNode> operandList,
List<? extends Type> storageTypes)
Translates the list of
RexNode, while optimizing for output
storage. |
List<Expression> |
translateList(List<RexNode> operandList,
RexImpTable.NullAs nullAs) |
static Expression |
translateLiteral(RexLiteral literal,
RelDataType type,
JavaTypeFactory typeFactory,
RexImpTable.NullAs nullAs)
Translates a literal.
|
static List<Expression> |
translateProjects(RexProgram program,
JavaTypeFactory typeFactory,
BlockBuilder list,
PhysType outputPhysType,
Expression root,
RexToLixTranslator.InputGetter inputGetter,
Function1<String,RexToLixTranslator.InputGetter> correlates)
Translates a
RexProgram to a sequence of expressions and
declarations. |
public static final Map<Method,SqlOperator> JAVA_TO_SQL_METHOD_MAP
public static List<Expression> translateProjects(RexProgram program, JavaTypeFactory typeFactory, BlockBuilder list, PhysType outputPhysType, Expression root, RexToLixTranslator.InputGetter inputGetter, Function1<String,RexToLixTranslator.InputGetter> correlates)
RexProgram to a sequence of expressions and
declarations.program - Program to be translatedtypeFactory - Type factorylist - List of statements, populated with declarationsoutputPhysType - Output type, or nullroot - Root expressioninputGetter - Generates expressions for inputscorrelates - Provider of references to the values of correlated
variablespublic static RexToLixTranslator forAggregation(JavaTypeFactory typeFactory, BlockBuilder list, RexToLixTranslator.InputGetter inputGetter)
public RexNode deref(RexNode expr)
RexLocalRef.public static Expression translateLiteral(RexLiteral literal, RelDataType type, JavaTypeFactory typeFactory, RexImpTable.NullAs nullAs)
AlwaysNull - if literal is null but nullAs is
RexImpTable.NullAs.NOT_POSSIBLE.public List<Expression> translateList(List<RexNode> operandList, RexImpTable.NullAs nullAs)
public List<Expression> translateList(List<? extends RexNode> operandList)
RexNode, using the default output types.
This might be suboptimal in terms of additional box-unbox when you use
the translation later.
If you know the java class that will be used to store the results, use
translateList(java.util.List, java.util.List)
version.operandList - list of RexNodes to translatepublic List<Expression> translateList(List<? extends RexNode> operandList, List<? extends Type> storageTypes)
RexNode, while optimizing for output
storage.
For instance, if the result of translation is going to be stored in
Object[], and the input is Object[] as well,
then translator will avoid casting, boxing, etc.operandList - list of RexNodes to translatestorageTypes - hints of the java classes that will be used
to store translation results. Use null to use
default storage typepublic static Expression translateCondition(RexProgram program, JavaTypeFactory typeFactory, BlockBuilder list, RexToLixTranslator.InputGetter inputGetter, Function1<String,RexToLixTranslator.InputGetter> correlates)
public static Expression convert(Expression operand, Type toType)
public Expression translateConstructor(List<RexNode> operandList, SqlKind kind)
public boolean isNullable(RexNode e)
For example, WHERE a == b translates to
a != null && b != null && a.equals(b). When translating the
3rd part of the disjunction, we already know a and b are not null.
e - Expressionprotected Boolean isKnownNullable(RexNode node)
node - RexNode to check if it is nullable or notpublic RexToLixTranslator setNullable(RexNode e, boolean nullable)
public RexToLixTranslator setNullable(Map<? extends RexNode,Boolean> nullable)
public RexToLixTranslator setBlock(BlockBuilder block)
public RexToLixTranslator setCorrelates(Function1<String,RexToLixTranslator.InputGetter> correlates)
public RelDataType nullifyType(RelDataType type, boolean nullable)
public Expression getRoot()
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.