You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "raminqaf (via GitHub)" <gi...@apache.org> on 2026/05/15 06:31:24 UTC

[PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

raminqaf opened a new pull request, #28163:
URL: https://github.com/apache/flink/pull/28163

   ## What is the purpose of the change
   
   The parser already accepted `ALTER MATERIALIZED TABLE t SET ('k' = 'v')`, but the planner had no converter registered for `SqlAlterMaterializedTableOptions`. As a result, the statement was rejected at plan time with `TableException: Unsupported query`.
   
   Add `SqlAlterMaterializedTableOptionsConverter` and register it in `SqlNodeConverters#registerMaterializedTableConverters`. The converter emits an `AlterMaterializedTableChangeOperation` with one `TableChange.set(key, value)` per option provided. Merge with existing options is handled by `MaterializedTableChangeHandler.setTableOption`, which mirrors the create-or-alter path established in FLINK-39199.
   
   Planner-level tests cover the success path, single-option summary string, unknown table, and applying SET to a regular table. A gateway IT test exercises the end-to-end flow in FULL refresh mode where the change is applied directly to the catalog. The user-facing docs are updated for the new SET clause.
   
   ## Brief change log
   
     - Add `SqlAlterMaterializedTableOptionsConverter`
     - register the new converter in `SqlNodeConverters#registerMaterializedTableConverters`
     - Planner-level tests
   
   
   ## Verifying this change
   
     - Added test in planner-level under `SqlMaterializedTableNodeToOperationConverterTest.java`
     - Added IT cases in `MaterializedTableStatementITCase.java`
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes)
     - If yes, how is the feature documented? (docs)
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, please
   change the checkbox below to `[X]` followed by the name of the tool, and uncomment the
   "Generated-by" line. See the ASF Generative Tooling Guidance for details:
   https://www.apache.org/legal/generative-tooling.html
   
   You are responsible for the quality and correctness of every change in this PR
   regardless of the tooling used. Low-effort AI-generated PRs will be closed. See
   AGENTS.md for the full guidance.
   -->
   
   - [X] Yes (please specify the tool below)
   
   
   Generated-by: Opus 4.7


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin merged PR #28163:
URL: https://github.com/apache/flink/pull/28163


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3252829192


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/materializedtable/SqlAlterMaterializedTableOptionsConverter.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.operations.converters.materializedtable;
+
+import org.apache.flink.sql.parser.SqlParseUtils;
+import org.apache.flink.sql.parser.ddl.SqlTableOption;
+import org.apache.flink.sql.parser.ddl.materializedtable.SqlAlterMaterializedTableOptions;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.ResolvedCatalogMaterializedTable;
+import org.apache.flink.table.catalog.TableChange;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.materializedtable.AlterMaterializedTableChangeOperation;
+
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+
+import java.util.List;
+import java.util.function.Function;
+
+/** A converter for {@link SqlAlterMaterializedTableOptions}. */
+public class SqlAlterMaterializedTableOptionsConverter
+        extends AbstractAlterMaterializedTableConverter<SqlAlterMaterializedTableOptions> {
+
+    @Override
+    protected Operation convertToOperation(
+            SqlAlterMaterializedTableOptions sqlAlterTable,
+            ResolvedCatalogMaterializedTable oldTable,
+            ConvertContext context) {
+        return new AlterMaterializedTableChangeOperation(
+                resolveIdentifier(sqlAlterTable, context),
+                gatherTableChanges(sqlAlterTable, context),
+                oldTable);
+    }
+
+    @Override
+    protected Function<ResolvedCatalogMaterializedTable, List<TableChange>> gatherTableChanges(
+            SqlAlterMaterializedTableOptions sqlAlterTable, ConvertContext context) {
+        final SqlNodeList propertyList = sqlAlterTable.getPropertyList();

Review Comment:
   do not use SqlNodeList
   rather use SqlParseUtils



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "raminqaf (via GitHub)" <gi...@apache.org>.
raminqaf commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3257075888


##########
docs/content/docs/sql/materialized-table/statements.md:
##########
@@ -548,6 +549,27 @@ ALTER MATERIALIZED TABLE my_materialized_table RESUME;
 ALTER MATERIALIZED TABLE my_materialized_table RESUME WITH ('sink.parallelism'='10');
 ```
 
+## SET
+
+```
+ALTER MATERIALIZED TABLE [catalog_name.][db_name.]table_name SET (key1=val1, key2=val2, ...)
+```
+
+`SET` is used to add or overwrite table options of a materialized table. Existing options not listed in the statement are preserved.

Review Comment:
   Updated the docs with the behavior. The latest key' value wins.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #28163:
URL: https://github.com/apache/flink/pull/28163#issuecomment-4476948814

   LGTM
   let's wait for ci


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "raminqaf (via GitHub)" <gi...@apache.org>.
raminqaf commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3264210405


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlMaterializedTableNodeToOperationConverterTest.java:
##########
@@ -523,6 +523,32 @@ void testAlterMaterializedTableResume() {
                 .isEqualTo("ALTER MATERIALIZED TABLE builtin.default.mtbl1 RESUME WITH (k1: [v1])");
     }
 
+    @Test
+    void testAlterMaterializedTableSet() {
+        final String sql =
+                "ALTER MATERIALIZED TABLE base_mtbl SET ('format' = 'json2', 'k1' = 'v1', 'k2' = 'v2', 'k2' = 'newV2')";
+        Operation operation = parse(sql);
+        assertThat(operation).isInstanceOf(AlterMaterializedTableChangeOperation.class);
+
+        AlterMaterializedTableChangeOperation op =
+                (AlterMaterializedTableChangeOperation) operation;
+        assertThat(op.getTableIdentifier().toString()).isEqualTo("`builtin`.`default`.`base_mtbl`");

Review Comment:
   Addressed and updated it in the other tests too



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3252829712


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/SqlParseUtils.java:
##########
@@ -101,16 +101,16 @@ public static Map<String, String> extractMap(@Nullable SqlNodeList propList) {
         return result;
     }
 
-    public static List<String> extractList(
-            @Nullable SqlNodeList sqlNodeList, Function<SqlNode, String> mapper) {
+    public static <T> List<T> extractList(

Review Comment:
   why do we need it?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28163:
URL: https://github.com/apache/flink/pull/28163#issuecomment-4457550400

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "b457f8b65da426c46ab988a44e84560f6abb7b5d",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b457f8b65da426c46ab988a44e84560f6abb7b5d",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b457f8b65da426c46ab988a44e84560f6abb7b5d UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3252833655


##########
docs/content/docs/sql/materialized-table/statements.md:
##########
@@ -548,6 +549,27 @@ ALTER MATERIALIZED TABLE my_materialized_table RESUME;
 ALTER MATERIALIZED TABLE my_materialized_table RESUME WITH ('sink.parallelism'='10');
 ```
 
+## SET
+
+```
+ALTER MATERIALIZED TABLE [catalog_name.][db_name.]table_name SET (key1=val1, key2=val2, ...)
+```
+
+`SET` is used to add or overwrite table options of a materialized table. Existing options not listed in the statement are preserved.

Review Comment:
   what happen for the case of same keys?
   ```sql
   ALTER MATERIALIZED TABLE [catalog_name.][db_name.]table_name SET (key1=val1, key1=val2, ...)
   ```



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3252830016


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/SqlParseUtils.java:
##########
@@ -101,16 +101,16 @@ public static Map<String, String> extractMap(@Nullable SqlNodeList propList) {
         return result;
     }
 
-    public static List<String> extractList(
-            @Nullable SqlNodeList sqlNodeList, Function<SqlNode, String> mapper) {
+    public static <T> List<T> extractList(

Review Comment:
   what else are you going to extract except for string?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "raminqaf (via GitHub)" <gi...@apache.org>.
raminqaf commented on PR #28163:
URL: https://github.com/apache/flink/pull/28163#issuecomment-4466215238

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "raminqaf (via GitHub)" <gi...@apache.org>.
raminqaf commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3257340309


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/materializedtable/SqlAlterMaterializedTableOptionsConverter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.operations.converters.materializedtable;
+
+import org.apache.flink.sql.parser.SqlParseUtils;
+import org.apache.flink.sql.parser.ddl.SqlTableOption;
+import org.apache.flink.sql.parser.ddl.materializedtable.SqlAlterMaterializedTableOptions;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.ResolvedCatalogMaterializedTable;
+import org.apache.flink.table.catalog.TableChange;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.materializedtable.AlterMaterializedTableChangeOperation;
+
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+
+import java.util.List;
+import java.util.function.Function;
+
+/** A converter for {@link SqlAlterMaterializedTableOptions}. */
+public class SqlAlterMaterializedTableOptionsConverter
+        extends AbstractAlterMaterializedTableConverter<SqlAlterMaterializedTableOptions> {
+
+    @Override
+    protected Operation convertToOperation(
+            SqlAlterMaterializedTableOptions sqlAlterTable,
+            ResolvedCatalogMaterializedTable oldTable,
+            ConvertContext context) {
+        return new AlterMaterializedTableChangeOperation(
+                resolveIdentifier(sqlAlterTable, context),
+                gatherTableChanges(sqlAlterTable, context),
+                oldTable);
+    }
+
+    @Override
+    protected Function<ResolvedCatalogMaterializedTable, List<TableChange>> gatherTableChanges(
+            SqlAlterMaterializedTableOptions sqlAlterTable, ConvertContext context) {
+        final SqlNodeList propertyList = sqlAlterTable.getPropertyList();
+        final List<TableChange> changes =
+                SqlParseUtils.extractList(
+                        propertyList, SqlAlterMaterializedTableOptionsConverter::toSetOption);
+        if (changes.isEmpty()) {

Review Comment:
   Makes sense!



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3264196176


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlMaterializedTableNodeToOperationConverterTest.java:
##########
@@ -523,6 +523,32 @@ void testAlterMaterializedTableResume() {
                 .isEqualTo("ALTER MATERIALIZED TABLE builtin.default.mtbl1 RESUME WITH (k1: [v1])");
     }
 
+    @Test
+    void testAlterMaterializedTableSet() {
+        final String sql =
+                "ALTER MATERIALIZED TABLE base_mtbl SET ('format' = 'json2', 'k1' = 'v1', 'k2' = 'v2', 'k2' = 'newV2')";
+        Operation operation = parse(sql);
+        assertThat(operation).isInstanceOf(AlterMaterializedTableChangeOperation.class);
+
+        AlterMaterializedTableChangeOperation op =
+                (AlterMaterializedTableChangeOperation) operation;
+        assertThat(op.getTableIdentifier().toString()).isEqualTo("`builtin`.`default`.`base_mtbl`");

Review Comment:
   ```suggestion
           assertThat(op.getTableIdentifier()).hasToString("`builtin`.`default`.`base_mtbl`");
   ```



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "raminqaf (via GitHub)" <gi...@apache.org>.
raminqaf commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3257069293


##########
flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/SqlParseUtils.java:
##########
@@ -101,16 +101,16 @@ public static Map<String, String> extractMap(@Nullable SqlNodeList propList) {
         return result;
     }
 
-    public static List<String> extractList(
-            @Nullable SqlNodeList sqlNodeList, Function<SqlNode, String> mapper) {
+    public static <T> List<T> extractList(

Review Comment:
   I was using to extract the TableChange from `SqlNodeList`: 
   ```java
   final List<TableChange> changes =
           SqlParseUtils.extractList(
                   propertyList, SqlAlterMaterializedTableOptionsConverter::toSetOption);
   ```



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "raminqaf (via GitHub)" <gi...@apache.org>.
raminqaf commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3257072703


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/materializedtable/SqlAlterMaterializedTableOptionsConverter.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.operations.converters.materializedtable;
+
+import org.apache.flink.sql.parser.SqlParseUtils;
+import org.apache.flink.sql.parser.ddl.SqlTableOption;
+import org.apache.flink.sql.parser.ddl.materializedtable.SqlAlterMaterializedTableOptions;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.ResolvedCatalogMaterializedTable;
+import org.apache.flink.table.catalog.TableChange;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.materializedtable.AlterMaterializedTableChangeOperation;
+
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+
+import java.util.List;
+import java.util.function.Function;
+
+/** A converter for {@link SqlAlterMaterializedTableOptions}. */
+public class SqlAlterMaterializedTableOptionsConverter
+        extends AbstractAlterMaterializedTableConverter<SqlAlterMaterializedTableOptions> {
+
+    @Override
+    protected Operation convertToOperation(
+            SqlAlterMaterializedTableOptions sqlAlterTable,
+            ResolvedCatalogMaterializedTable oldTable,
+            ConvertContext context) {
+        return new AlterMaterializedTableChangeOperation(
+                resolveIdentifier(sqlAlterTable, context),
+                gatherTableChanges(sqlAlterTable, context),
+                oldTable);
+    }
+
+    @Override
+    protected Function<ResolvedCatalogMaterializedTable, List<TableChange>> gatherTableChanges(
+            SqlAlterMaterializedTableOptions sqlAlterTable, ConvertContext context) {
+        final SqlNodeList propertyList = sqlAlterTable.getPropertyList();

Review Comment:
   `SqlParseUtils#extractList` requires `SqlNodeList` as its first param



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3257328955


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/materializedtable/SqlAlterMaterializedTableOptionsConverter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.operations.converters.materializedtable;
+
+import org.apache.flink.sql.parser.SqlParseUtils;
+import org.apache.flink.sql.parser.ddl.SqlTableOption;
+import org.apache.flink.sql.parser.ddl.materializedtable.SqlAlterMaterializedTableOptions;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.ResolvedCatalogMaterializedTable;
+import org.apache.flink.table.catalog.TableChange;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.materializedtable.AlterMaterializedTableChangeOperation;
+
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+
+import java.util.List;
+import java.util.function.Function;
+
+/** A converter for {@link SqlAlterMaterializedTableOptions}. */
+public class SqlAlterMaterializedTableOptionsConverter
+        extends AbstractAlterMaterializedTableConverter<SqlAlterMaterializedTableOptions> {
+
+    @Override
+    protected Operation convertToOperation(
+            SqlAlterMaterializedTableOptions sqlAlterTable,
+            ResolvedCatalogMaterializedTable oldTable,
+            ConvertContext context) {
+        return new AlterMaterializedTableChangeOperation(
+                resolveIdentifier(sqlAlterTable, context),
+                gatherTableChanges(sqlAlterTable, context),
+                oldTable);
+    }
+
+    @Override
+    protected Function<ResolvedCatalogMaterializedTable, List<TableChange>> gatherTableChanges(
+            SqlAlterMaterializedTableOptions sqlAlterTable, ConvertContext context) {
+        final SqlNodeList propertyList = sqlAlterTable.getPropertyList();
+        final List<TableChange> changes =
+                SqlParseUtils.extractList(
+                        propertyList, SqlAlterMaterializedTableOptionsConverter::toSetOption);
+        if (changes.isEmpty()) {

Review Comment:
   if latest key wins, we can extract it with set, maintaining in set only last values, right?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion [flink]

Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #28163:
URL: https://github.com/apache/flink/pull/28163#discussion_r3257331566


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/materializedtable/SqlAlterMaterializedTableOptionsConverter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.operations.converters.materializedtable;
+
+import org.apache.flink.sql.parser.SqlParseUtils;
+import org.apache.flink.sql.parser.ddl.SqlTableOption;
+import org.apache.flink.sql.parser.ddl.materializedtable.SqlAlterMaterializedTableOptions;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.ResolvedCatalogMaterializedTable;
+import org.apache.flink.table.catalog.TableChange;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.materializedtable.AlterMaterializedTableChangeOperation;
+
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+
+import java.util.List;
+import java.util.function.Function;
+
+/** A converter for {@link SqlAlterMaterializedTableOptions}. */
+public class SqlAlterMaterializedTableOptionsConverter
+        extends AbstractAlterMaterializedTableConverter<SqlAlterMaterializedTableOptions> {
+
+    @Override
+    protected Operation convertToOperation(
+            SqlAlterMaterializedTableOptions sqlAlterTable,
+            ResolvedCatalogMaterializedTable oldTable,
+            ConvertContext context) {
+        return new AlterMaterializedTableChangeOperation(
+                resolveIdentifier(sqlAlterTable, context),
+                gatherTableChanges(sqlAlterTable, context),
+                oldTable);
+    }
+
+    @Override
+    protected Function<ResolvedCatalogMaterializedTable, List<TableChange>> gatherTableChanges(
+            SqlAlterMaterializedTableOptions sqlAlterTable, ConvertContext context) {
+        final SqlNodeList propertyList = sqlAlterTable.getPropertyList();
+        final List<TableChange> changes =
+                SqlParseUtils.extractList(
+                        propertyList, SqlAlterMaterializedTableOptionsConverter::toSetOption);
+        if (changes.isEmpty()) {

Review Comment:
   also probably makes sense to have a test for such case



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org