public abstract class SqlImplementor extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
SqlImplementor.AliasContext
Implementation of Context that precedes field references with their
"table alias" based on the current sub-query's FROM clause.
|
protected class |
SqlImplementor.BaseContext
Implementation of
SqlImplementor.Context that has an enclosing
SqlImplementor and can therefore do non-trivial expressions. |
class |
SqlImplementor.Builder
Builder.
|
static class |
SqlImplementor.Clause
Clauses in a SQL query.
|
static class |
SqlImplementor.Context
|
class |
SqlImplementor.MatchRecognizeContext
Context for translating MATCH_RECOGNIZE clause.
|
class |
SqlImplementor.Result
Result of implementing a node.
|
static class |
SqlImplementor.SimpleContext
Simple implementation of
SqlImplementor.Context that cannot handle sub-queries
or correlations. |
| Modifier and Type | Field and Description |
|---|---|
protected Set<String> |
aliasSet |
protected Map<CorrelationId,SqlImplementor.Context> |
correlTableMap |
SqlDialect |
dialect |
static SqlParserPos |
POS |
| Modifier | Constructor and Description |
|---|---|
protected |
SqlImplementor(SqlDialect dialect) |
| Modifier and Type | Method and Description |
|---|---|
void |
addSelect(List<SqlNode> selectList,
SqlNode node,
RelDataType rowType) |
SqlImplementor.Context |
aliasContext(Map<String,RelDataType> aliases,
boolean qualified) |
protected SqlCall |
as(SqlNode e,
String alias,
String... fieldNames)
Convenience method for creating column and table aliases.
|
static SqlNode |
convertConditionToSqlNode(RexNode node,
SqlImplementor.Context leftContext,
SqlImplementor.Context rightContext)
|
protected boolean |
isAnon()
Returns whether to remove trivial aliases such as "EXPR$0"
when converting the current relational expression into a SELECT.
|
static boolean |
isStar(List<RexNode> exps,
RelDataType inputRowType,
RelDataType projectRowType)
Returns whether a list of expressions projects all fields, in order,
from the input, with the same names.
|
static boolean |
isStar(RexProgram program) |
SqlImplementor.Context |
joinContext(SqlImplementor.Context leftContext,
SqlImplementor.Context rightContext) |
static JoinType |
joinType(JoinRelType joinType) |
SqlImplementor.Context |
matchRecognizeContext(SqlImplementor.Context context) |
SqlImplementor.Result |
result(SqlNode node,
Collection<SqlImplementor.Clause> clauses,
RelNode rel,
@Nullable Map<String,RelDataType> aliases)
Creates a result based on a single relational expression.
|
protected SqlImplementor.Result |
result(SqlNode node,
Collection<SqlImplementor.Clause> clauses,
@Nullable String neededAlias,
@Nullable RelDataType neededType,
Map<String,RelDataType> aliases)
Factory method for
SqlImplementor.Result. |
SqlImplementor.Result |
result(SqlNode join,
SqlImplementor.Result leftResult,
SqlImplementor.Result rightResult)
Creates a result based on a join.
|
SqlImplementor.Result |
setOpToSql(SqlSetOperator operator,
RelNode rel) |
SqlImplementor.Context |
tableFunctionScanContext(List<SqlNode> inputSqlNodes) |
static SqlNode |
toSql(RexLiteral literal)
Converts a
RexLiteral to a SqlLiteral. |
static SqlNode |
toSql(@Nullable RexProgram program,
RexLiteral literal)
|
SqlImplementor.Result |
visitChild(int i,
RelNode e)
Deprecated.
Use either
visitRoot(RelNode) or
visitInput(RelNode, int). |
SqlImplementor.Result |
visitInput(RelNode e,
int i)
Visits an input of the current relational expression,
deducing
anon using isAnon(). |
abstract SqlImplementor.Result |
visitInput(RelNode e,
int i,
boolean anon,
boolean ignoreClauses,
Set<SqlImplementor.Clause> expectedClauses)
Visits the
ith input of e, the current relational
expression. |
SqlImplementor.Result |
visitInput(RelNode e,
int i,
Set<SqlImplementor.Clause> clauses)
Visits an input of the current relational expression,
deducing
anon using isAnon(). |
SqlImplementor.Result |
visitInput(RelNode e,
int i,
SqlImplementor.Clause... clauses)
Visits an input of the current relational expression,
with the given expected clauses.
|
SqlImplementor.Result |
visitRoot(RelNode r)
Visits a relational expression that has no parent.
|
public static final SqlParserPos POS
public final SqlDialect dialect
protected final Map<CorrelationId,SqlImplementor.Context> correlTableMap
protected SqlImplementor(SqlDialect dialect)
public final SqlImplementor.Result visitRoot(RelNode r)
@Deprecated public final SqlImplementor.Result visitChild(int i, RelNode e)
visitRoot(RelNode) or
visitInput(RelNode, int).public final SqlImplementor.Result visitInput(RelNode e, int i)
anon using isAnon().public final SqlImplementor.Result visitInput(RelNode e, int i, SqlImplementor.Clause... clauses)
public final SqlImplementor.Result visitInput(RelNode e, int i, Set<SqlImplementor.Clause> clauses)
anon using isAnon().public abstract SqlImplementor.Result visitInput(RelNode e, int i, boolean anon, boolean ignoreClauses, Set<SqlImplementor.Clause> expectedClauses)
ith input of e, the current relational
expression.e - Current relational expressioni - Ordinal of input within eanon - Whether to remove trivial aliases such as "EXPR$0"ignoreClauses - Whether to ignore the expected clauses when deciding
whether a sub-query is requiredexpectedClauses - Set of clauses that we expect the builder that
consumes this result will createisAnon()public void addSelect(List<SqlNode> selectList, SqlNode node, RelDataType rowType)
protected SqlCall as(SqlNode e, String alias, String... fieldNames)
AS(e, "c") creates "e AS c";
AS(e, "t", "c1", "c2" creates "e AS t (c1, c2)".
public static boolean isStar(List<RexNode> exps, RelDataType inputRowType, RelDataType projectRowType)
public static boolean isStar(RexProgram program)
public SqlImplementor.Result setOpToSql(SqlSetOperator operator, RelNode rel)
public static SqlNode convertConditionToSqlNode(RexNode node, SqlImplementor.Context leftContext, SqlImplementor.Context rightContext)
node - Join conditionleftContext - Left contextrightContext - Right contextpublic static JoinType joinType(JoinRelType joinType)
public SqlImplementor.Result result(SqlNode node, Collection<SqlImplementor.Clause> clauses, RelNode rel, @Nullable Map<String,RelDataType> aliases)
protected SqlImplementor.Result result(SqlNode node, Collection<SqlImplementor.Clause> clauses, @Nullable String neededAlias, @Nullable RelDataType neededType, Map<String,RelDataType> aliases)
SqlImplementor.Result.
Call this method rather than creating a Result directly,
because sub-classes may override.
public SqlImplementor.Result result(SqlNode join, SqlImplementor.Result leftResult, SqlImplementor.Result rightResult)
protected boolean isAnon()
For example, INSERT does not care about field names; we would prefer to generate without the "EXPR$0" alias:
INSERT INTO t1 SELECT x, y + 1 FROM t2
rather than with it:
INSERT INTO t1 SELECT x, y + 1 AS EXPR$0 FROM t2
But JOIN does care about field names; we have to generate the "EXPR$0" alias:
SELECT *
FROM emp AS e
JOIN (SELECT x, y + 1 AS EXPR$0) AS d
ON e.deptno = d.EXPR$0
because if we omit "AS EXPR$0" we do not know the field we are joining to, and the following is invalid:
SELECT *
FROM emp AS e
JOIN (SELECT x, y + 1) AS d
ON e.deptno = d.EXPR$0
public static SqlNode toSql(@Nullable RexProgram program, RexLiteral literal)
public static SqlNode toSql(RexLiteral literal)
RexLiteral to a SqlLiteral.public SqlImplementor.Context aliasContext(Map<String,RelDataType> aliases, boolean qualified)
public SqlImplementor.Context joinContext(SqlImplementor.Context leftContext, SqlImplementor.Context rightContext)
public SqlImplementor.Context matchRecognizeContext(SqlImplementor.Context context)
public SqlImplementor.Context tableFunctionScanContext(List<SqlNode> inputSqlNodes)
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.