You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/10/11 07:22:07 UTC

[GitHub] [inlong] healchow commented on a diff in pull request #6128: [INLONG-6113][Sort] Mysql cdc connector support read table schema when using debezium function

healchow commented on code in PR #6128:
URL: https://github.com/apache/inlong/pull/6128#discussion_r991904447


##########
inlong-sort/sort-connectors/mysql-cdc/src/main/java/org/apache/inlong/sort/cdc/mysql/table/MySqlReadableMetadata.java:
##########
@@ -432,7 +427,27 @@ public static Map<String, String> getMysqlType(@Nullable TableChanges.TableChang
         return mysqlType;
     }
 
-    private static String getMetaData(SourceRecord record, String tableNameKey) {
+    /**
+     * get sql type from table schema, represents the jdbc data type
+     * @param tableSchema
+     */
+    public static Map<String, Integer> getSqlType(@Nullable TableChanges.TableChange tableSchema) {
+        if (tableSchema == null) {
+            return null;
+        }
+        Map<String, Integer> sqlType = new HashMap<>();
+        final Table table = tableSchema.getTable();
+        table.columns()
+            .forEach(
+                column -> {
+                    sqlType.put(
+                        column.name(),
+                        column.jdbcType());
+                });
+        return sqlType;
+    }

Review Comment:
   ```suggestion
       /**
        * get sql type from table schema, represents the jdbc data type
        *
        * @param tableSchema table schema
        */
       public static Map<String, Integer> getSqlType(@Nullable TableChanges.TableChange tableSchema) {
           if (tableSchema == null) {
               return null;
           }
           Map<String, Integer> sqlType = new HashMap<>();
           final Table table = tableSchema.getTable();
           table.columns().forEach(
                   column -> sqlType.put(column.name(), column.jdbcType())
           );
           return sqlType;
       }
   ```



-- 
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: commits-unsubscribe@inlong.apache.org

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