Class SqlHandlerUtil
java.lang.Object
org.apache.drill.exec.planner.sql.handlers.SqlHandlerUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
dropTableFromSchema
(AbstractSchema drillSchema, String tableName) Drops table from schema.static void
dropViewFromSchema
(AbstractSchema drillSchema, String viewName) Drops view from schema.static org.apache.calcite.schema.Table
getTableFromSchema
(AbstractSchema drillSchema, String tblName) static org.apache.calcite.rel.RelNode
qualifyPartitionCol
(org.apache.calcite.rel.RelNode input, List<String> partitionColumns) Resolve the partition columns specified in "PARTITION BY" clause of CTAS statement.static org.apache.calcite.rel.RelNode
resolveNewTableRel
(boolean isNewTableView, List<String> tableFieldNames, org.apache.calcite.rel.type.RelDataType validatedRowtype, org.apache.calcite.rel.RelNode queryRelNode) Resolve final RelNode of the new table (or view) for given table field list and new table definition.static void
unparseKeyValuePairs
(org.apache.calcite.sql.SqlWriter writer, int leftPrec, int rightPrec, org.apache.calcite.sql.SqlNodeList list) Unparses givenSqlNodeList
into key / values pairs: (k1 = v1, k2 = v2).static void
unparseSqlNodeList
(org.apache.calcite.sql.SqlWriter writer, int leftPrec, int rightPrec, org.apache.calcite.sql.SqlNodeList fieldList)
-
Constructor Details
-
SqlHandlerUtil
public SqlHandlerUtil()
-
-
Method Details
-
resolveNewTableRel
public static org.apache.calcite.rel.RelNode resolveNewTableRel(boolean isNewTableView, List<String> tableFieldNames, org.apache.calcite.rel.type.RelDataType validatedRowtype, org.apache.calcite.rel.RelNode queryRelNode) throws org.apache.calcite.tools.ValidationException, org.apache.calcite.tools.RelConversionException Resolve final RelNode of the new table (or view) for given table field list and new table definition.- Parameters:
isNewTableView
- Is the new table created a view? This doesn't affect the functionality, but it helps format better error messages.tableFieldNames
- List of fields specified in new table/view field list. These are the fields given just after new table name. Ex. CREATE TABLE newTblName(col1, medianOfCol2, avgOfCol3) AS SELECT col1, median(col2), avg(col3) FROM sourcetbl GROUP BY col1;- Throws:
org.apache.calcite.tools.ValidationException
- If table's fields list and field list specified in table definition are not valid.org.apache.calcite.tools.RelConversionException
- If failed to convert the table definition into a RelNode.
-
qualifyPartitionCol
public static org.apache.calcite.rel.RelNode qualifyPartitionCol(org.apache.calcite.rel.RelNode input, List<String> partitionColumns) Resolve the partition columns specified in "PARTITION BY" clause of CTAS statement. A partition column is resolved, either (1) the same column appear in the select list of CTAS or (2) CTAS has a * in select list. In the second case, a PROJECT with ITEM expression would be created and returned. Throw validation error if a partition column is not resolved correctly.- Parameters:
input
- : the RelNode represents the select statement in CTAS.partitionColumns
- : the list of partition columns.- Returns:
- : 1) the original RelNode input, if all partition columns are in select list of CTAS 2) a New Project, if a partition column is resolved to * column in select list 3) validation error, if partition column is not resolved.
-
getTableFromSchema
public static org.apache.calcite.schema.Table getTableFromSchema(AbstractSchema drillSchema, String tblName) -
unparseSqlNodeList
public static void unparseSqlNodeList(org.apache.calcite.sql.SqlWriter writer, int leftPrec, int rightPrec, org.apache.calcite.sql.SqlNodeList fieldList) -
dropTableFromSchema
Drops table from schema. If drop has failed makes concurrency check: checks if table still exists. If table exists, throwsUserException
since drop was unsuccessful, otherwise assumes that other user had dropped the view and exists without error.- Parameters:
drillSchema
- drill schematableName
- table name
-
dropViewFromSchema
public static void dropViewFromSchema(AbstractSchema drillSchema, String viewName) throws IOException Drops view from schema. If drop has failed makes concurrency check: checks if view still exists. If view exists, throwsUserException
since drop was unsuccessful, otherwise assumes that other user had dropped the view and exists without error.- Parameters:
drillSchema
- drill schemaviewName
- view name- Throws:
IOException
-
unparseKeyValuePairs
public static void unparseKeyValuePairs(org.apache.calcite.sql.SqlWriter writer, int leftPrec, int rightPrec, org.apache.calcite.sql.SqlNodeList list) Unparses givenSqlNodeList
into key / values pairs: (k1 = v1, k2 = v2).- Parameters:
writer
- sql writerleftPrec
- left precedencerightPrec
- right precedencelist
- sql node list
-