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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to