zhuangchong commented on code in PR #2220:
URL: https://github.com/apache/incubator-paimon/pull/2220#discussion_r1382776368


##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlRecordParser.java:
##########
@@ -211,87 +168,83 @@ public List<DataField> parseSchemaChange() {
                 return Collections.emptyList();
             }
         } catch (Exception e) {
-            LOG.info("Failed to parse history record for schema changes", e);
+            LOG.error("Failed to parse history record for schema changes", e);
+            return Collections.emptyList();
+        }
+
+        if (TableChanges.TableChangeType.CREATE == tableChange.getType()
+                && tableChange.getTable().primaryKeyColumnNames().isEmpty()) {
+            LOG.error(
+                    "Didn't find primary keys from MySQL DDL for table '{}'. "
+                            + "This table won't be synchronized.",
+                    currentTable);
+            nonPkTables.add(currentTable);
             return Collections.emptyList();
         }
 
-        Optional<Schema> schema = schemaBuilder.build(tableChange);
-        return schema.get().fields();
+        nonPkTables.remove(currentTable);

Review Comment:
   done.



##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlSyncDatabaseAction.java:
##########
@@ -284,28 +286,26 @@ public void build() throws Exception {
                                 monitoredTables,
                                 excludedTables));
 
-        String serverTimeZone = 
mySqlConfig.get(MySqlSourceOptions.SERVER_TIME_ZONE);
-        ZoneId zoneId = serverTimeZone == null ? ZoneId.systemDefault() : 
ZoneId.of(serverTimeZone);
-        TypeMapping typeMapping = this.typeMapping;
-        MySqlTableSchemaBuilder schemaBuilder =
-                new MySqlTableSchemaBuilder(tableConfig, caseSensitive, 
typeMapping);
+        RichCdcMultiplexRecordSchemaBuilder schemaBuilder =
+                new RichCdcMultiplexRecordSchemaBuilder(tableConfig, 
caseSensitive);
 
-        EventParser.Factory<String> parserFactory =
+        TypeMapping typeMapping = this.typeMapping;
+        MySqlRecordParser recordParser =
+                new MySqlRecordParser(mySqlConfig, caseSensitive, typeMapping, 
metadataConverters);
+        EventParser.Factory<RichCdcMultiplexRecord> parserFactory =
                 () ->
-                        new MySqlDebeziumJsonEventParser(
-                                zoneId,
-                                caseSensitive,
-                                tableNameConverter,
+                        new RichCdcMultiplexRecordEventParser(
                                 schemaBuilder,
                                 includingPattern,
                                 excludingPattern,
-                                typeMapping,
-                                metadataConverters);
+                                tableNameConverter);
 
         String database = this.database;
         MultiTablesSinkMode mode = this.mode;
-        new FlinkCdcSyncDatabaseSinkBuilder<String>()
-                .withInput(env.fromSource(source, 
WatermarkStrategy.noWatermarks(), "MySQL Source"))
+        new FlinkCdcSyncDatabaseSinkBuilder<RichCdcMultiplexRecord>()
+                .withInput(
+                        env.fromSource(source, 
WatermarkStrategy.noWatermarks(), "MySQL Source")
+                                .flatMap(recordParser))

Review Comment:
   done.



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