Class MergeTableAsUtil
- java.lang.Object
-
- org.apache.flink.table.planner.operations.MergeTableAsUtil
-
public class MergeTableAsUtil extends Object
A utility class with logic for handling theCREATE TABLE ... AS SELECT
clause.
-
-
Constructor Summary
Constructors Constructor Description MergeTableAsUtil(org.apache.calcite.sql.validate.SqlValidator validator, Function<org.apache.calcite.sql.SqlNode,String> escapeExpression, DataTypeFactory dataTypeFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlannerQueryOperation
maybeRewriteQuery(CatalogManager catalogManager, org.apache.flink.table.planner.calcite.FlinkPlannerImpl flinkPlanner, PlannerQueryOperation origQueryOperation, org.apache.calcite.sql.SqlNode origQueryNode, ResolvedCatalogTable sinkTable)
Rewrites the query operation to include only the fields that may be persisted in the sink.Schema
mergeSchemas(org.apache.calcite.sql.SqlNodeList sqlColumnList, SqlWatermark sqlWatermark, List<SqlTableConstraint> sqlTableConstraints, ResolvedSchema sourceSchema)
Merges the specified schema with columns, watermark, and constraints with thesourceSchema
.Schema
reorderSchema(org.apache.calcite.sql.SqlNodeList sqlColumnList, ResolvedSchema sourceSchema)
Reorders the columns from the source schema based on the columns identifiers list.
-
-
-
Constructor Detail
-
MergeTableAsUtil
public MergeTableAsUtil(org.apache.calcite.sql.validate.SqlValidator validator, Function<org.apache.calcite.sql.SqlNode,String> escapeExpression, DataTypeFactory dataTypeFactory)
-
-
Method Detail
-
maybeRewriteQuery
public PlannerQueryOperation maybeRewriteQuery(CatalogManager catalogManager, org.apache.flink.table.planner.calcite.FlinkPlannerImpl flinkPlanner, PlannerQueryOperation origQueryOperation, org.apache.calcite.sql.SqlNode origQueryNode, ResolvedCatalogTable sinkTable)
Rewrites the query operation to include only the fields that may be persisted in the sink.
-
mergeSchemas
public Schema mergeSchemas(org.apache.calcite.sql.SqlNodeList sqlColumnList, @Nullable SqlWatermark sqlWatermark, List<SqlTableConstraint> sqlTableConstraints, ResolvedSchema sourceSchema)
Merges the specified schema with columns, watermark, and constraints with thesourceSchema
.The resulted schema will contain the following elements:
- columns
- computed columns
- metadata columns
- watermarks
- primary key
It is expected that the
sourceSchema
contains only physical/regular columns.Columns of the
sourceSchema
are appended to the schema columns defined in thesqlColumnList
. If a column in thesqlColumnList
is already defined in thesourceSchema
, then the types of the columns are implicit cast and must be compatible based on the implicit cast rules. If they're compatible, then the column position in the schema stays the same as defined in the appendedsourceSchema
.
-
reorderSchema
public Schema reorderSchema(org.apache.calcite.sql.SqlNodeList sqlColumnList, ResolvedSchema sourceSchema)
Reorders the columns from the source schema based on the columns identifiers list.
-
-