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/19 09:15:34 UTC

[GitHub] [flink] xuzhiwen1255 commented on a diff in pull request #22213: [FLINK-31514][table-planner] Move query SqlNode conversion logic to SqlQueryConverter

xuzhiwen1255 commented on code in PR #22213:
URL: https://github.com/apache/flink/pull/22213#discussion_r1141304360


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConverters.java:
##########
@@ -46,19 +49,51 @@ public class SqlNodeConverters {
     @SuppressWarnings({"unchecked", "rawtypes"})
     public static Optional<Operation> convertSqlNode(
             SqlNode validatedSqlNode, ConvertContext context) {
-        SqlNodeConverter converter = CONVERTERS.get(validatedSqlNode.getClass());
-        if (converter != null) {
-            return Optional.of(converter.convertSqlNode(validatedSqlNode, context));
+        // match by class first
+        SqlNodeConverter classConverter = CLASS_CONVERTERS.get(validatedSqlNode.getClass());
+        if (classConverter != null) {
+            return Optional.of(classConverter.convertSqlNode(validatedSqlNode, context));
+        }
+
+        // match by kind
+        SqlNodeConverter sqlKindConverter = SQLKIND_CONVERTERS.get(validatedSqlNode.getKind());
+        if (sqlKindConverter != null) {
+            return Optional.of(sqlKindConverter.convertSqlNode(validatedSqlNode, context));
         } else {
             return Optional.empty();
         }
     }
 
     private static void register(SqlNodeConverter<?> converter) {
+        // register by SqlKind if it is defined

Review Comment:
   +1, I think this is better, through the class to obtain, with some common features still need to write a separate Converter, in fact is more redundant.



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