public class SqlValidatorUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
SqlValidatorUtil.DeepCopier
Walks over an expression, copying every node, and fully-qualifying every
identifier.
|
| Modifier and Type | Field and Description |
|---|---|
static org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester |
EXPR_SUGGESTER |
static org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester |
F_SUGGESTER |
| Modifier and Type | Method and Description |
|---|---|
static SqlNode |
addAlias(SqlNode expr,
String alias)
Converts an expression "expr" into "expr AS alias".
|
static void |
analyzeGroupItem(SqlValidatorScope scope,
List<SqlNode> groupExprs,
Map<Integer,Integer> groupExprProjection,
com.google.common.collect.ImmutableList.Builder<com.google.common.collect.ImmutableList<ImmutableBitSet>> topBuilder,
SqlNode groupExpr)
Analyzes an expression in a GROUP BY clause.
|
static void |
checkCharsetAndCollateConsistentIfCharType(RelDataType type) |
static RelDataType |
createTypeFromProjection(RelDataType type,
List<String> columnNameList,
RelDataTypeFactory typeFactory,
boolean caseSensitive,
boolean elideRecord) |
static com.google.common.collect.ImmutableList<ImmutableBitSet> |
cube(List<ImmutableBitSet> bitSets)
Computes the cube of bit sets.
|
static List<String> |
deriveNaturalJoinColumnList(RelDataType leftRowType,
RelDataType rightRowType)
Derives the list of column names suitable for NATURAL JOIN.
|
static String |
getAlias(SqlNode node,
int ordinal)
Derives an alias for a node, and invents a mangled identifier if it
cannot.
|
static AggregatingSelectScope |
getEnclosingAggregateSelectScope(SqlValidatorScope scope) |
static SelectScope |
getEnclosingSelectScope(SqlValidatorScope scope) |
static RelOptTable |
getRelOptTable(SqlValidatorNamespace namespace,
Prepare.CatalogReader catalogReader,
String datasetName,
boolean[] usedDataset)
Converts a
SqlValidatorScope into a RelOptTable. |
static void |
getSchemaObjectMonikers(SqlValidatorCatalogReader catalogReader,
List<String> names,
List<SqlMoniker> hints) |
static SqlValidatorNamespace |
lookup(SqlValidatorScope scope,
List<String> names)
Resolves a multi-part identifier such as "SCHEMA.EMP.EMPNO" to a
namespace.
|
static RelDataTypeField |
lookupField(boolean caseSensitive,
boolean elideRecord,
RelDataType rowType,
String columnName)
Looks up a field with a given name, returning null if not found.
|
static SqlValidatorWithHints |
newValidator(SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory)
Factory method for
SqlValidator. |
static com.google.common.collect.ImmutableList<ImmutableBitSet> |
rollup(List<ImmutableBitSet> bitSets)
Computes the rollup of bit sets.
|
static List<String> |
uniquify(List<String> nameList)
Makes sure that the names in a list are unique.
|
static List<String> |
uniquify(List<String> nameList,
org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester suggester) |
static String |
uniquify(String name,
Set<String> nameList,
org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester suggester)
Makes a name distinct from other names which have already been used, adds
it to the list, and returns it.
|
public static final org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester EXPR_SUGGESTER
public static final org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester F_SUGGESTER
public static RelOptTable getRelOptTable(SqlValidatorNamespace namespace, Prepare.CatalogReader catalogReader, String datasetName, boolean[] usedDataset)
SqlValidatorScope into a RelOptTable. This is
only possible if the scope represents an identifier, such as "sales.emp".
Otherwise, returns null.namespace - NamespacecatalogReader - SchemadatasetName - Name of sample dataset to substitute, or null to use
the regular tableusedDataset - Output parameter which is set to true if a sample
dataset is found; may be nullpublic static RelDataTypeField lookupField(boolean caseSensitive, boolean elideRecord, RelDataType rowType, String columnName)
caseSensitive - Whether match is case-sensitiveelideRecord - Whether to find fields nested within recordsrowType - Row typecolumnName - Field namepublic static void checkCharsetAndCollateConsistentIfCharType(RelDataType type)
public static SqlNode addAlias(SqlNode expr, String alias)
public static String getAlias(SqlNode node, int ordinal)
Examples:
public static String uniquify(String name, Set<String> nameList, org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester suggester)
name - Suggested name, may not be uniquenameList - Collection of names already usedsuggester - Base for name when input name is nullpublic static SqlValidatorWithHints newValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory)
SqlValidator.public static List<String> uniquify(List<String> nameList)
Does not modify the input list. Returns the input list if the strings are unique, otherwise allocates a new list.
nameList - List of stringspublic static List<String> uniquify(List<String> nameList, org.apache.calcite.sql.validate.SqlValidatorUtil.Suggester suggester)
public static SqlValidatorNamespace lookup(SqlValidatorScope scope, List<String> names)
public static void getSchemaObjectMonikers(SqlValidatorCatalogReader catalogReader, List<String> names, List<SqlMoniker> hints)
public static SelectScope getEnclosingSelectScope(SqlValidatorScope scope)
public static AggregatingSelectScope getEnclosingAggregateSelectScope(SqlValidatorScope scope)
public static List<String> deriveNaturalJoinColumnList(RelDataType leftRowType, RelDataType rightRowType)
leftRowType - Row type of left input to the joinrightRowType - Row type of right input to the joinpublic static RelDataType createTypeFromProjection(RelDataType type, List<String> columnNameList, RelDataTypeFactory typeFactory, boolean caseSensitive, boolean elideRecord)
public static void analyzeGroupItem(SqlValidatorScope scope, List<SqlNode> groupExprs, Map<Integer,Integer> groupExprProjection, com.google.common.collect.ImmutableList.Builder<com.google.common.collect.ImmutableList<ImmutableBitSet>> topBuilder, SqlNode groupExpr)
It may be an expression, an empty list (), or a call to
GROUPING SETS, CUBE or ROLLUP.
Each group item produces a list of group sets, which are written to
topBuilder. To find the grouping sets of the query, we will take
the cartesian product of the group sets.
public static com.google.common.collect.ImmutableList<ImmutableBitSet> rollup(List<ImmutableBitSet> bitSets)
For example, rollup({0}, {1})
returns ({0, 1}, {0}, {}).
Bit sets are not necessarily singletons:
rollup({0, 2}, {3, 5})
returns ({0, 2, 3, 5}, {0, 2}, {}).
public static com.google.common.collect.ImmutableList<ImmutableBitSet> cube(List<ImmutableBitSet> bitSets)
For example, rollup({0}, {1})
returns ({0, 1}, {0}, {}).
Bit sets are not necessarily singletons:
rollup({0, 2}, {3, 5})
returns ({0, 2, 3, 5}, {0, 2}, {}).
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.