Class MergeTableAsUtil


  • public class MergeTableAsUtil
    extends Object
    A utility class with logic for handling the CREATE TABLE ... AS SELECT clause.
    • 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 the sourceSchema.

        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 the sqlColumnList. If a column in the sqlColumnList is already defined in the sourceSchema, 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 appended sourceSchema.

      • 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.