|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.sql.validate.SqlValidatorUtil
public class SqlValidatorUtil
Utility methods related to validation.
Nested Class Summary | |
---|---|
static class |
SqlValidatorUtil.DeepCopier
Walks over an expression, copying every node, and fully-qualifying every identifier. |
Constructor Summary | |
---|---|
SqlValidatorUtil()
|
Method Summary | |
---|---|
static SqlNode |
addAlias(SqlNode expr,
String alias)
Converts an expression "expr" into "expr AS alias". |
static void |
checkCharsetAndCollateConsistentIfCharType(RelDataType type)
|
(package private) static int |
countOccurrences(String name,
String[] names)
|
static List<String> |
deriveNaturalJoinColumnList(RelDataType leftRowType,
RelDataType rightRowType)
Derives the list of column names suitable for NATURAL JOIN. |
static String |
getAlias(SqlNode node)
Derives an alias for a node. |
static String |
getAlias(SqlNode node,
int ordinal)
Derives an alias for a node, and invents a mangled identifier if it cannot. |
static SelectScope |
getEnclosingSelectScope(SqlValidatorScope scope)
|
static RelOptTable |
getRelOptTable(SqlValidatorNamespace namespace,
RelOptSchema schema,
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 int |
lookupField(RelDataType rowType,
String columnName)
Looks up a field with a given name and if found returns its ordinal. |
(package private) static RelDataType |
lookupFieldType(RelDataType rowType,
String columnName)
Looks up a field with a given name and if found returns its type. |
static SqlValidatorWithHints |
newValidator(SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory)
Factory method for SqlValidator . |
static void |
uniquify(List<String> nameList)
Makes sure that the names in a list are unique. |
static String |
uniquify(String name,
Collection<String> nameList)
Makes a name distinct from other names which have already been used, adds it to the list, and returns it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SqlValidatorUtil()
Method Detail |
---|
public static RelOptTable getRelOptTable(SqlValidatorNamespace namespace, RelOptSchema schema, 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
- Namespaceschema
- 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 nullstatic RelDataType lookupFieldType(RelDataType rowType, String columnName)
rowType
- Row typecolumnName
- Field name
public static int lookupField(RelDataType rowType, String columnName)
rowType
- Row typecolumnName
- Field name
public static void checkCharsetAndCollateConsistentIfCharType(RelDataType type)
public static SqlNode addAlias(SqlNode expr, String alias)
public static String getAlias(SqlNode node)
This method doesn't try very hard. It doesn't invent mangled aliases,
and doesn't even recognize an AS clause. (See getAlias(SqlNode,
int)
for that.) It just takes the last part of an identifier.
public static String getAlias(SqlNode node, int ordinal)
Examples:
public static String uniquify(String name, Collection<String> nameList)
name
- Suggested name, may not be uniquenameList
- Collection of names already used
public static SqlValidatorWithHints newValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory)
SqlValidator
.
public static void uniquify(List<String> nameList)
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 List<String> deriveNaturalJoinColumnList(RelDataType leftRowType, RelDataType rightRowType)
leftRowType
- Row type of left input to the joinrightRowType
- Row type of right input to the join
static int countOccurrences(String name, String[] names)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |