twalthr commented on code in PR #28287: URL: https://github.com/apache/flink/pull/28287#discussion_r3396556059
########## docs/content.zh/docs/sql/materialized-table/statements.md: ########## @@ -260,6 +261,63 @@ The operation updates the materialized table similarly to [ALTER MATERIALIZED TA See [ALTER MATERIALIZED TABLE AS](#as-select_statement-1) for more details. +## Converting a Table to a Materialized Table + +This lets you adopt a materialized table on top of a table that already exists, without dropping and recreating it. + +`CREATE OR ALTER MATERIALIZED TABLE` can convert an existing regular table into a materialized table in place. The catalog object keeps its identity and underlying storage. Its kind becomes materialized table, and its schema, options, query definition, freshness, and refresh mode are taken from the conversion statement, exactly as for a newly created materialized table. After the conversion, a refresh job is launched just as it is for a newly created materialized table. + + +**Enabling conversion** + +Conversion is disabled by default. When the option is disabled, `CREATE OR ALTER MATERIALIZED TABLE` against a regular table is rejected. +To enable it, set the following option in the cluster configuration file `config.yaml`: + +```yaml +table.materialized-table.conversion-from-table.enabled: true +``` + +This is a cluster-wide setting: it must be set in the cluster configuration, and a session-level `SET` statement has no effect. Review Comment: It doesn't need to be defined in `config.yaml`. It just "needs to be set during TableEnvironment session initialization." ########## docs/content.zh/docs/sql/materialized-table/statements.md: ########## @@ -260,6 +261,63 @@ The operation updates the materialized table similarly to [ALTER MATERIALIZED TA See [ALTER MATERIALIZED TABLE AS](#as-select_statement-1) for more details. +## Converting a Table to a Materialized Table + +This lets you adopt a materialized table on top of a table that already exists, without dropping and recreating it. + +`CREATE OR ALTER MATERIALIZED TABLE` can convert an existing regular table into a materialized table in place. The catalog object keeps its identity and underlying storage. Its kind becomes materialized table, and its schema, options, query definition, freshness, and refresh mode are taken from the conversion statement, exactly as for a newly created materialized table. After the conversion, a refresh job is launched just as it is for a newly created materialized table. + + +**Enabling conversion** + +Conversion is disabled by default. When the option is disabled, `CREATE OR ALTER MATERIALIZED TABLE` against a regular table is rejected. +To enable it, set the following option in the cluster configuration file `config.yaml`: + +```yaml +table.materialized-table.conversion-from-table.enabled: true +``` + +This is a cluster-wide setting: it must be set in the cluster configuration, and a session-level `SET` statement has no effect. + +**Schema, watermark, and primary key** + +The materialized table's schema is derived from the `CREATE OR ALTER MATERIALIZED TABLE` statement and its query, exactly as for a newly created materialized table. The source table's watermark and primary key are **not** carried over — declare them in the conversion statement if you want them. This keeps `CREATE OR ALTER MATERIALIZED TABLE` declarative and idempotent: running the same statement again produces the same materialized table. Review Comment: This sentence doesn't convince me. Why is discarding information "idempotent" ########## docs/content.zh/docs/sql/materialized-table/statements.md: ########## @@ -260,6 +261,63 @@ The operation updates the materialized table similarly to [ALTER MATERIALIZED TA See [ALTER MATERIALIZED TABLE AS](#as-select_statement-1) for more details. +## Converting a Table to a Materialized Table + +This lets you adopt a materialized table on top of a table that already exists, without dropping and recreating it. + +`CREATE OR ALTER MATERIALIZED TABLE` can convert an existing regular table into a materialized table in place. The catalog object keeps its identity and underlying storage. Its kind becomes materialized table, and its schema, options, query definition, freshness, and refresh mode are taken from the conversion statement, exactly as for a newly created materialized table. After the conversion, a refresh job is launched just as it is for a newly created materialized table. + + +**Enabling conversion** + +Conversion is disabled by default. When the option is disabled, `CREATE OR ALTER MATERIALIZED TABLE` against a regular table is rejected. Review Comment: Why disabled by default? ########## docs/content.zh/docs/sql/materialized-table/statements.md: ########## @@ -260,6 +261,63 @@ The operation updates the materialized table similarly to [ALTER MATERIALIZED TA See [ALTER MATERIALIZED TABLE AS](#as-select_statement-1) for more details. +## Converting a Table to a Materialized Table + +This lets you adopt a materialized table on top of a table that already exists, without dropping and recreating it. + +`CREATE OR ALTER MATERIALIZED TABLE` can convert an existing regular table into a materialized table in place. The catalog object keeps its identity and underlying storage. Its kind becomes materialized table, and its schema, options, query definition, freshness, and refresh mode are taken from the conversion statement, exactly as for a newly created materialized table. After the conversion, a refresh job is launched just as it is for a newly created materialized table. Review Comment: it would be good to have a dedicated section on schema. does the query has to be 100% like the query? do we insert implicit casts. what happens with computed/metadata columns. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
