You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "MonsterChenzhuo (via GitHub)" <gi...@apache.org> on 2023/09/26 13:21:54 UTC
[GitHub] [incubator-paimon] MonsterChenzhuo opened a new pull request, #2077: [WIP][flink] CDC Ingestion supported metadata columns
MonsterChenzhuo opened a new pull request, #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077
<!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
### Purpose
close #1985
<!-- What is the purpose of the change -->
### Tests
<!-- List UT and IT cases to verify this change -->
### API and Format
<!-- Does this change affect API or storage format -->
### Documentation
<!-- Does this change introduce a new feature -->
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "MonsterChenzhuo (via GitHub)" <gi...@apache.org>.
MonsterChenzhuo commented on code in PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#discussion_r1349516662
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#discussion_r1349498588
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
Review Comment:
dbName?
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "database_name";
+ }
+ }),
+
+ /**
+ * It indicates the time that the change was made in the database. If the record is read from
+ * snapshot of the table instead of the binlog, the value is always 0.
+ */
+ OP_TS(
+ "op_ts",
+ DataTypes.TIMESTAMP(3).notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
Review Comment:
dbName?
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/CdcMetadataConverter.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc;
+
+import org.apache.paimon.types.DataType;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * A functional interface for converting CDC metadata.
+ *
+ * <p>This interface provides a mechanism to convert Change Data Capture (CDC) metadata from a given
+ * {@link JsonNode} source. Implementations of this interface can be used to process and transform
+ * metadata entries from CDC sources.
+ */
+public interface CdcMetadataConverter extends Serializable {
+
+ Map<String, String> read(JsonNode var1);
Review Comment:
var1 to a meaningful name
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "database_name";
+ }
+ }),
+
+ /**
+ * It indicates the time that the change was made in the database. If the record is read from
+ * snapshot of the table instead of the binlog, the value is always 0.
+ */
+ OP_TS(
+ "op_ts",
+ DataTypes.TIMESTAMP(3).notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TIMESTAMP_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("op_ts", dbName);
+ return resultMap;
Review Comment:
`Collections.singletonMap`
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
Review Comment:
`Collections.singletonMap`
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
Review Comment:
`Collections.singletonMap`
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlDebeziumJsonEventParser.java:
##########
@@ -416,6 +425,10 @@ else if (Date.SCHEMA_NAME.equals(className)) {
computedColumn.eval(resultMap.get(computedColumn.fieldReference())));
}
+ for (CdcMetadataConverter metadataConverters : metadataConverters) {
Review Comment:
`metadataConverter`
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "MonsterChenzhuo (via GitHub)" <gi...@apache.org>.
MonsterChenzhuo commented on code in PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#discussion_r1349515534
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "database_name";
+ }
+ }),
+
+ /**
+ * It indicates the time that the change was made in the database. If the record is read from
+ * snapshot of the table instead of the binlog, the value is always 0.
+ */
+ OP_TS(
+ "op_ts",
+ DataTypes.TIMESTAMP(3).notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
Review Comment:
<img width="1070" alt="图片" src="https://github.com/apache/incubator-paimon/assets/60029759/ec8fa016-b654-4d3c-b4c7-0e62415a010c">
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "MonsterChenzhuo (via GitHub)" <gi...@apache.org>.
MonsterChenzhuo commented on code in PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#discussion_r1349516556
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "database_name";
+ }
+ }),
+
+ /**
+ * It indicates the time that the change was made in the database. If the record is read from
+ * snapshot of the table instead of the binlog, the value is always 0.
+ */
+ OP_TS(
+ "op_ts",
+ DataTypes.TIMESTAMP(3).notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TIMESTAMP_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("op_ts", dbName);
+ return resultMap;
Review Comment:
done.
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
Review Comment:
done.
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlDebeziumJsonEventParser.java:
##########
@@ -416,6 +425,10 @@ else if (Date.SCHEMA_NAME.equals(className)) {
computedColumn.eval(resultMap.get(computedColumn.fieldReference())));
}
+ for (CdcMetadataConverter metadataConverters : metadataConverters) {
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "MonsterChenzhuo (via GitHub)" <gi...@apache.org>.
MonsterChenzhuo commented on code in PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#discussion_r1349515534
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "database_name";
+ }
+ }),
+
+ /**
+ * It indicates the time that the change was made in the database. If the record is read from
+ * snapshot of the table instead of the binlog, the value is always 0.
+ */
+ OP_TS(
+ "op_ts",
+ DataTypes.TIMESTAMP(3).notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
Review Comment:
<img width="1070" alt="图片" src="https://github.com/apache/incubator-paimon/assets/60029759/ec8fa016-b654-4d3c-b4c7-0e62415a010c">
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "database_name";
+ }
+ }),
+
+ /**
+ * It indicates the time that the change was made in the database. If the record is read from
+ * snapshot of the table instead of the binlog, the value is always 0.
+ */
+ OP_TS(
+ "op_ts",
+ DataTypes.TIMESTAMP(3).notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
Review Comment:
<img width="1070" alt="图片" src="https://github.com/apache/incubator-paimon/assets/60029759/ec8fa016-b654-4d3c-b4c7-0e62415a010c">
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "MonsterChenzhuo (via GitHub)" <gi...@apache.org>.
MonsterChenzhuo closed pull request #2077: [flink] CDC Ingestion supported metadata columns
URL: https://github.com/apache/incubator-paimon/pull/2077
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#issuecomment-1751650528
Please rebase master
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "MonsterChenzhuo (via GitHub)" <gi...@apache.org>.
MonsterChenzhuo commented on PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#issuecomment-1751662808
@JingsongLi PTAL,thanks.
--
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@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] CDC Ingestion supported metadata columns [incubator-paimon]
Posted by "MonsterChenzhuo (via GitHub)" <gi...@apache.org>.
MonsterChenzhuo commented on code in PR #2077:
URL: https://github.com/apache/incubator-paimon/pull/2077#discussion_r1349516581
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/CdcMetadataConverter.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc;
+
+import org.apache.paimon.types.DataType;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * A functional interface for converting CDC metadata.
+ *
+ * <p>This interface provides a mechanism to convert Change Data Capture (CDC) metadata from a given
+ * {@link JsonNode} source. Implementations of this interface can be used to process and transform
+ * metadata entries from CDC sources.
+ */
+public interface CdcMetadataConverter extends Serializable {
+
+ Map<String, String> read(JsonNode var1);
Review Comment:
done.
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
Review Comment:
done.
##########
paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/mysql/MySqlMetadataProcessor.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.flink.action.cdc.mysql;
+
+import org.apache.paimon.flink.action.cdc.CdcMetadataConverter;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypes;
+
+import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import io.debezium.connector.AbstractSourceInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Enumerates the metadata processing behaviors for MySQL CDC related data.
+ *
+ * <p>This enumeration provides definitions for various MySQL CDC metadata keys along with their
+ * associated data types and converters. Each enum entry represents a specific type of metadata
+ * related to MySQL CDC and provides a mechanism to read and process this metadata from a given
+ * {@link JsonNode} source.
+ *
+ * <p>The provided converters, which are of type {@link CdcMetadataConverter}, define how the raw
+ * metadata is transformed or processed for each specific metadata key.
+ */
+public enum MySqlMetadataProcessor {
+ /** Name of the table that contain the row. */
+ TABLE_NAME(
+ "table_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.TABLE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("table_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "table_name";
+ }
+ }),
+
+ /** Name of the database that contain the row. */
+ DATABASE_NAME(
+ "database_name",
+ DataTypes.STRING().notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
+ record.get("source").get(AbstractSourceInfo.DATABASE_NAME_KEY).asText();
+ Map<String, String> resultMap = new HashMap<>();
+ resultMap.put("database_name", dbName);
+ return resultMap;
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataTypes.STRING().notNull();
+ }
+
+ @Override
+ public String getColumnName() {
+ return "database_name";
+ }
+ }),
+
+ /**
+ * It indicates the time that the change was made in the database. If the record is read from
+ * snapshot of the table instead of the binlog, the value is always 0.
+ */
+ OP_TS(
+ "op_ts",
+ DataTypes.TIMESTAMP(3).notNull(),
+ new CdcMetadataConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Map<String, String> read(JsonNode record) {
+ String dbName =
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org