raminqaf commented on code in PR #28287:
URL: https://github.com/apache/flink/pull/28287#discussion_r3412591957


##########
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:
   Re-written it. The wording was a bit confusing here. Keeping the 
parimary-key and watermark information in the CoA makes the query idempotent. 



-- 
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]

Reply via email to