yuxiqian commented on code in PR #3357:
URL: https://github.com/apache/flink-cdc/pull/3357#discussion_r1612544048


##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/JaninoCompiler.java:
##########
@@ -298,4 +312,33 @@ private static Java.Rvalue 
generateNoOperandTimestampFunctionOperation(String op
                 StringUtils.convertToCamelCase(operationName),
                 timestampFunctionParam.toArray(new Java.Rvalue[0]));
     }
+
+    private static String getTypeConvertMethod(SqlDataTypeSpec 
sqlDataTypeSpec) {
+        switch (sqlDataTypeSpec.getTypeName().getSimple().toUpperCase()) {
+            case "BOOLEAN":
+                return "convertBoolean";
+            case "TINYINT":
+                return "convertByte";
+            case "SMALLINT":
+                return "convertShort";
+            case "INTEGER":
+                return "convertInteger";
+            case "BIGINT":
+                return "convertLong";
+            case "FLOAT":
+                return "convertFloat";
+            case "DOUBLE":
+                return "convertDouble";
+            case "DECIMAL":
+                return "convertBigDecimal";
+            case "CHAR":
+            case "VARCHAR":
+            case "STRING":
+            case "`STRING`":
+                return "convertString";
+            default:
+                throw new ParseException(
+                        "Unsupported data type convert: " + 
sqlDataTypeSpec.toString());

Review Comment:
   ```suggestion
                   throw new ParseException(
                           "Unsupported data type cast: " + 
sqlDataTypeSpec.toString());
   ```
   
   Using cast might be better since user writes `cast` instead of `convert` 
keyword in YAML



##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/JaninoCompiler.java:
##########
@@ -298,4 +312,33 @@ private static Java.Rvalue 
generateNoOperandTimestampFunctionOperation(String op
                 StringUtils.convertToCamelCase(operationName),
                 timestampFunctionParam.toArray(new Java.Rvalue[0]));
     }
+
+    private static String getTypeConvertMethod(SqlDataTypeSpec 
sqlDataTypeSpec) {
+        switch (sqlDataTypeSpec.getTypeName().getSimple().toUpperCase()) {
+            case "BOOLEAN":
+                return "convertBoolean";
+            case "TINYINT":
+                return "convertByte";
+            case "SMALLINT":
+                return "convertShort";
+            case "INTEGER":
+                return "convertInteger";
+            case "BIGINT":
+                return "convertLong";
+            case "FLOAT":
+                return "convertFloat";
+            case "DOUBLE":
+                return "convertDouble";
+            case "DECIMAL":
+                return "convertBigDecimal";
+            case "CHAR":
+            case "VARCHAR":
+            case "STRING":
+            case "`STRING`":

Review Comment:
   Seems only the STRING type is specially treated to handle the quoted 
version. Will other types be quoted too? If so, maybe we can trim typename 
first before `switch` cases.



-- 
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-unsubscr...@flink.apache.org

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

Reply via email to