You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "xuzhiwen1255 (via GitHub)" <gi...@apache.org> on 2023/03/18 05:47:50 UTC

[GitHub] [flink] xuzhiwen1255 opened a new pull request, #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   ## What is the purpose of the change
   Similar to [FLINK-31368](https://issues.apache.org/jira/browse/FLINK-31368), the SqlToOperationConverter is a bit bloated. 
   This PR moves the conversion logic into CreateTableConverter
   
   ## Brief change log
   - Add SqlNodeConverter implementation of SqlCreateTableAs, SqlCreateTable and SqlCreateTableLike
   - SqlNodeConverter.ConvertContext adds the method of obtaining FlinkPlannerImpl
   
   ## Verifying this change
   This change is already covered by existing tests, such as (please describe tests).
   
   ## 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, Yarn/Mesos, ZooKeeper: 
    no
   The S3 file system connector:  no 
   
   ## Documentation
   Does this pull request introduce a new feature?  no
   If yes, how is the feature documented? not applicable 


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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   Thanks for @wuchong, according to the comments, I reworked the code, PTAL.


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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @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


[GitHub] [flink] xuzhiwen1255 commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConverters.java:
##########
@@ -37,9 +40,9 @@ public class SqlNodeConverters {
     static {
         // register all the converters here
         register(new SqlCreateCatalogConverter());
-        register(new SqlCreateTableAsConverter());
-        register(new SqlCreateTableLikeConverter());
-        register(new SqlCreateTableConverter());
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTable.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableAs.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableLike.class));

Review Comment:
   Or create separate SqlNodeConverter for SqlCreateTableAs and SqlCreateTableLike.



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


[GitHub] [flink] wuchong commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   Please do not use "git merge" to merge branches, otherwise the changes is hard to track. Please use "git rebase" to rebase branches instead. IntelliJ IDEA provide an easy tool to do git rebase, you can find the tool via `VCS -> Git -> Rebase`.


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


[GitHub] [flink] wuchong commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlCreateTableLikeConverter.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import org.apache.flink.sql.parser.ddl.SqlCreateTableLike;
+import org.apache.flink.table.operations.Operation;
+
+import static org.apache.flink.table.planner.operations.CreateTableConverterUtils.convertCreateTable;
+
+/** A converter for {@link SqlCreateTableLike}. */
+public class SqlCreateTableLikeConverter implements SqlNodeConverter<SqlCreateTableLike> {
+
+    @Override
+    public Operation convertSqlNode(SqlCreateTableLike node, ConvertContext context) {
+        return convertCreateTable(context, node);

Review Comment:
   You can simply call `return new SqlCreateTableConverter().convertSqlNode(node, context);` to reuse the conversion logic if we would move the util there. 



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlCreateTableConverter.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import org.apache.flink.sql.parser.ddl.SqlCreateTable;
+import org.apache.flink.table.operations.Operation;
+
+import static org.apache.flink.table.planner.operations.CreateTableConverterUtils.convertCreateTable;
+
+/** A converter for {@link SqlCreateTable}. */
+public class SqlCreateTableConverter implements SqlNodeConverter<SqlCreateTable> {
+
+    @Override
+    public Operation convertSqlNode(SqlCreateTable node, ConvertContext context) {
+        return convertCreateTable(context, node);

Review Comment:
   This makes the design of `SqlNodeConverter` less useful because the core logic is out of it. Please move the implementation of `convertCreateTable` here.



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlCreateTableAsConverter.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+import org.apache.flink.sql.parser.ddl.SqlCreateTableAs;
+import org.apache.flink.table.operations.Operation;
+
+import static org.apache.flink.table.planner.operations.CreateTableConverterUtils.convertCreateTableAs;
+
+/** A converter for {@link SqlCreateTableAs}. */
+public class SqlCreateTableAsConverter implements SqlNodeConverter<SqlCreateTableAs> {
+    @Override
+    public Operation convertSqlNode(SqlCreateTableAs node, ConvertContext context) {
+        return convertCreateTableAs(context, node);

Review Comment:
   Please move the implementation of `convertCreateTableAs` here.



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/CreateTableConverterUtils.java:
##########
@@ -85,8 +74,10 @@ Operation convertCreateTable(SqlCreateTable sqlCreateTable) {
     }
 
     /** Convert the {@link SqlCreateTableAs} node. */
-    Operation convertCreateTableAS(
-            FlinkPlannerImpl flinkPlanner, SqlCreateTableAs sqlCreateTableAs) {
+    public static Operation convertCreateTableAs(
+            SqlNodeConverter.ConvertContext context, SqlCreateTableAs sqlCreateTableAs) {
+        CatalogManager catalogManager = context.getCatalogManager();
+        FlinkPlannerImpl flinkPlanner = context.getFlinkPlannerImpl();

Review Comment:
   I'm trying not to expose `FlinkPlannerImpl` to the converters because it pulls out many complex objects. I think we can simply call `SqlNodeConverters#convertSqlNode(sqlCreateTableAs.getAsQuery(), context)` once we migrate query conversion. 



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/CreateTableConverterUtils.java:
##########
@@ -50,32 +49,22 @@
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
-/** Helper class for converting {@link SqlCreateTable} to {@link CreateTableOperation}. */
-class SqlCreateTableConverter {
+/** A utility class for {@link SqlCreateTable} conversion. */
+public class CreateTableConverterUtils {
 
-    private final MergeTableLikeUtil mergeTableLikeUtil;
-    private final CatalogManager catalogManager;
+    private CreateTableConverterUtils() {}
 
-    SqlCreateTableConverter(
-            FlinkCalciteSqlValidator sqlValidator,
-            CatalogManager catalogManager,
-            Function<SqlNode, String> escapeExpression) {
-        this.mergeTableLikeUtil =
-                new MergeTableLikeUtil(
-                        sqlValidator, escapeExpression, catalogManager.getDataTypeFactory());
-        this.catalogManager = catalogManager;
-    }
-
-    /** Convert the {@link SqlCreateTable} node. */
-    Operation convertCreateTable(SqlCreateTable sqlCreateTable) {
-        CatalogTable catalogTable = createCatalogTable(sqlCreateTable);
+    /** Convert {@link SqlCreateTable} or {@link SqlCreateTableAs} node. */

Review Comment:
   ```suggestion
       /** Convert {@link SqlCreateTable} or {@link SqlCreateTableLike} node. */
   ```



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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @wuchong Compiled through.


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


[GitHub] [flink] xuzhiwen1255 commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlCreateTableConverter.java:
##########
@@ -50,51 +49,30 @@
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
-/** Helper class for converting {@link SqlCreateTable} to {@link CreateTableOperation}. */
-class SqlCreateTableConverter {
+/** A converter for {@link SqlCreateTable}. */
+public class SqlCreateTableConverter implements SqlNodeConverter<SqlCreateTable> {
 
-    private final MergeTableLikeUtil mergeTableLikeUtil;
-    private final CatalogManager catalogManager;
-
-    SqlCreateTableConverter(
-            FlinkCalciteSqlValidator sqlValidator,
-            CatalogManager catalogManager,
-            Function<SqlNode, String> escapeExpression) {
-        this.mergeTableLikeUtil =
-                new MergeTableLikeUtil(
-                        sqlValidator, escapeExpression, catalogManager.getDataTypeFactory());
-        this.catalogManager = catalogManager;
-    }
-
-    /** Convert the {@link SqlCreateTable} node. */
-    Operation convertCreateTable(SqlCreateTable sqlCreateTable) {
-        CatalogTable catalogTable = createCatalogTable(sqlCreateTable);
-
-        UnresolvedIdentifier unresolvedIdentifier =
-                UnresolvedIdentifier.of(sqlCreateTable.fullTableName());
-        ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
-
-        return new CreateTableOperation(
-                identifier,
-                catalogTable,
-                sqlCreateTable.isIfNotExists(),
-                sqlCreateTable.isTemporary());
+    @Override
+    public Operation convertSqlNode(SqlCreateTable node, ConvertContext context) {
+        if (node instanceof SqlCreateTableAs) {
+            return convertCreateTableAs(context, (SqlCreateTableAs) node);
+        }
+        return convertCreateTable(context, node);
     }
 
     /** Convert the {@link SqlCreateTableAs} node. */
-    Operation convertCreateTableAS(
-            FlinkPlannerImpl flinkPlanner, SqlCreateTableAs sqlCreateTableAs) {
+    public Operation convertCreateTableAs(
+            SqlNodeConverter.ConvertContext context, SqlCreateTableAs sqlCreateTableAs) {
+        CatalogManager catalogManager = context.getCatalogManager();
         UnresolvedIdentifier unresolvedIdentifier =
                 UnresolvedIdentifier.of(sqlCreateTableAs.fullTableName());
         ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
 
         PlannerQueryOperation query =
                 (PlannerQueryOperation)
-                        SqlNodeToOperationConversion.convert(
-                                        flinkPlanner, catalogManager, sqlCreateTableAs.getAsQuery())
+                        SqlNodeConverters.convertSqlNode(sqlCreateTableAs.getAsQuery(), context)

Review Comment:
   Thank you @wuchong , I think it can work after your PR is integrated.



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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @wuchong wu @luoyuxia luo Please take a look, thank you very much.


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


[GitHub] [flink] xuzhiwen1255 commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConverters.java:
##########
@@ -37,9 +40,9 @@ public class SqlNodeConverters {
     static {
         // register all the converters here
         register(new SqlCreateCatalogConverter());
-        register(new SqlCreateTableAsConverter());
-        register(new SqlCreateTableLikeConverter());
-        register(new SqlCreateTableConverter());
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTable.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableAs.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableLike.class));

Review Comment:
   I have revised it back.



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


[GitHub] [flink] wuchong commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlCreateTableConverter.java:
##########
@@ -50,51 +49,30 @@
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
-/** Helper class for converting {@link SqlCreateTable} to {@link CreateTableOperation}. */
-class SqlCreateTableConverter {
+/** A converter for {@link SqlCreateTable}. */
+public class SqlCreateTableConverter implements SqlNodeConverter<SqlCreateTable> {
 
-    private final MergeTableLikeUtil mergeTableLikeUtil;
-    private final CatalogManager catalogManager;
-
-    SqlCreateTableConverter(
-            FlinkCalciteSqlValidator sqlValidator,
-            CatalogManager catalogManager,
-            Function<SqlNode, String> escapeExpression) {
-        this.mergeTableLikeUtil =
-                new MergeTableLikeUtil(
-                        sqlValidator, escapeExpression, catalogManager.getDataTypeFactory());
-        this.catalogManager = catalogManager;
-    }
-
-    /** Convert the {@link SqlCreateTable} node. */
-    Operation convertCreateTable(SqlCreateTable sqlCreateTable) {
-        CatalogTable catalogTable = createCatalogTable(sqlCreateTable);
-
-        UnresolvedIdentifier unresolvedIdentifier =
-                UnresolvedIdentifier.of(sqlCreateTable.fullTableName());
-        ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
-
-        return new CreateTableOperation(
-                identifier,
-                catalogTable,
-                sqlCreateTable.isIfNotExists(),
-                sqlCreateTable.isTemporary());
+    @Override
+    public Operation convertSqlNode(SqlCreateTable node, ConvertContext context) {
+        if (node instanceof SqlCreateTableAs) {
+            return convertCreateTableAs(context, (SqlCreateTableAs) node);
+        }
+        return convertCreateTable(context, node);
     }
 
     /** Convert the {@link SqlCreateTableAs} node. */
-    Operation convertCreateTableAS(
-            FlinkPlannerImpl flinkPlanner, SqlCreateTableAs sqlCreateTableAs) {
+    public Operation convertCreateTableAs(
+            SqlNodeConverter.ConvertContext context, SqlCreateTableAs sqlCreateTableAs) {
+        CatalogManager catalogManager = context.getCatalogManager();
         UnresolvedIdentifier unresolvedIdentifier =
                 UnresolvedIdentifier.of(sqlCreateTableAs.fullTableName());
         ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
 
         PlannerQueryOperation query =
                 (PlannerQueryOperation)
-                        SqlNodeToOperationConversion.convert(
-                                        flinkPlanner, catalogManager, sqlCreateTableAs.getAsQuery())
+                        SqlNodeConverters.convertSqlNode(sqlCreateTableAs.getAsQuery(), context)

Review Comment:
   This doesn't work for now because we didn't migrate the query SqlNode yet, and the build failed with ["CTAS unsupported node type SqlSelect"](https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=47331&view=logs&j=0c940707-2659-5648-cbe6-a1ad63045f0a&t=075c2716-8010-5565-fe08-3c4bb45824a4).
   
   I have submitted a pull request for migrating the query SqlNode #22213



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


[GitHub] [flink] xuzhiwen1255 commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlCreateTableAsConverter.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+import org.apache.flink.sql.parser.ddl.SqlCreateTableAs;
+import org.apache.flink.table.api.Schema;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.CatalogTable;
+import org.apache.flink.table.catalog.ObjectIdentifier;
+import org.apache.flink.table.catalog.UnresolvedIdentifier;
+import org.apache.flink.table.operations.CreateTableASOperation;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.ddl.CreateTableOperation;
+import org.apache.flink.table.planner.operations.PlannerQueryOperation;
+
+import org.apache.calcite.sql.SqlNode;
+
+import java.util.Collections;
+
+import static org.apache.flink.table.planner.operations.CreateTableConverterUtils.createCatalogTable;
+
+/** A converter for {@link SqlCreateTableAs}. */
+public class SqlCreateTableAsConverter implements SqlNodeConverter<SqlCreateTableAs> {
+    @Override
+    public Operation convertSqlNode(SqlCreateTableAs node, ConvertContext context) {
+        return convertCreateTableAs(context, node);
+    }
+
+    public Operation convertCreateTableAs(
+            SqlNodeConverter.ConvertContext context, SqlCreateTableAs sqlCreateTableAs) {
+        CatalogManager catalogManager = context.getCatalogManager();
+        UnresolvedIdentifier unresolvedIdentifier =
+                UnresolvedIdentifier.of(sqlCreateTableAs.fullTableName());
+        ObjectIdentifier identifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
+
+        SqlNode asQuery = sqlCreateTableAs.getAsQuery();

Review Comment:
   The sqlNode has no validate. I accidentally ignored 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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @wuchong  If you have time, please check back. Thank you.


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


[GitHub] [flink] flinkbot commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d7e324b18d000d6f46e3bfde2dbd654c3dda08c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "5d7e324b18d000d6f46e3bfde2dbd654c3dda08c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d7e324b18d000d6f46e3bfde2dbd654c3dda08c 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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @wuchong gentle ping, please come and have a look, I've got it done, I think it should work.


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


[GitHub] [flink] xuzhiwen1255 commented on pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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

   @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


[GitHub] [flink] wuchong commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConverters.java:
##########
@@ -37,9 +40,9 @@ public class SqlNodeConverters {
     static {
         // register all the converters here
         register(new SqlCreateCatalogConverter());
-        register(new SqlCreateTableAsConverter());
-        register(new SqlCreateTableLikeConverter());
-        register(new SqlCreateTableConverter());
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTable.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableAs.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableLike.class));

Review Comment:
   IMO, this breaks the design of `SqlNodeConverter` somehow. The principle of `SqlNodeConverter` focuses on a single kind of SqlNode conversion, but this involves `if else` and `instance of` which we would like to avoid in `SqlNodeToOperationConversion`.
   
   Is there any problems to continue the way of 3 separate converters?



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


[GitHub] [flink] xuzhiwen1255 commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConverters.java:
##########
@@ -37,9 +40,9 @@ public class SqlNodeConverters {
     static {
         // register all the converters here
         register(new SqlCreateCatalogConverter());
-        register(new SqlCreateTableAsConverter());
-        register(new SqlCreateTableLikeConverter());
-        register(new SqlCreateTableConverter());
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTable.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableAs.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableLike.class));

Review Comment:
   Yes, there will be the following situation:
   If I only register one SqlCreateTable converter, other subclasses will not be able to obtain the instance of the SqlCreateTable converter, because when registering, I get the SqlCreateTable class as the Key through type analysis, and for subclasses: such as SqlCreateTableAs, it is Use the SqlCreateTableAs type as a key to find the converter, so it is not available.



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


[GitHub] [flink] wuchong commented on a diff in pull request #22208: [FLINK-31499] [table-planner] Move SqlCreateTable conversion logic to SqlCreateTableConverter

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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConverters.java:
##########
@@ -37,9 +40,9 @@ public class SqlNodeConverters {
     static {
         // register all the converters here
         register(new SqlCreateCatalogConverter());
-        register(new SqlCreateTableAsConverter());
-        register(new SqlCreateTableLikeConverter());
-        register(new SqlCreateTableConverter());
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTable.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableAs.class));
+        register(new SqlCreateTableConverter(), TypeInformation.of(SqlCreateTableLike.class));

Review Comment:
   Yes, that what I mean "3 separate converters" and that is how you did in the first commit. 



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