/** * Resolve final RelNode of the new table (or view) for given table field list and new table definition. * * @param isNewTableView Is the new table created a view? This doesn't affect the functionality, but it helps format * better error messages. * @param 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 ValidationException If table's fields list and field list specified in table definition are not valid. * @throws RelConversionException If failed to convert the table definition into a RelNode. */ public static RelNode resolveNewTableRel(boolean isNewTableView, List<String> tableFieldNames, RelDataType validatedRowtype, RelNode queryRelNode) throws ValidationException, RelConversionException { validateRowType(isNewTableView, tableFieldNames, validatedRowtype); if (tableFieldNames.size() > 0) { return MoreRelOptUtil.createRename(queryRelNode, tableFieldNames); } // As the column names of the view are derived from SELECT query, make sure the query has no duplicate column names ensureNoDuplicateColumnNames(validatedRowtype.getFieldNames()); return queryRelNode; }
SqlHandlerUtil.validateRowType(true, Lists.<String>newArrayList(), rowType);