tub commented on code in PR #6353: URL: https://github.com/apache/paimon/pull/6353#discussion_r2387579578
########## paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/kafka/KafkaMetadataConverter.java: ########## @@ -0,0 +1,181 @@ +/* + * 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.kafka; + +import org.apache.paimon.data.Timestamp; +import org.apache.paimon.flink.action.cdc.CdcMetadataConverter; +import org.apache.paimon.flink.action.cdc.CdcSourceRecord; +import org.apache.paimon.types.DataType; +import org.apache.paimon.types.DataTypes; +import org.apache.paimon.utils.DateTimeUtils; + +import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode; + +import java.util.TimeZone; + +/** + * Kafka-specific implementations of {@link CdcMetadataConverter} for extracting Kafka message + * metadata. + * + * <p>These converters read from the generic metadata map in {@link CdcSourceRecord} to extract + * Kafka-specific metadata like topic, partition, offset, timestamp, and timestamp type. + */ +public class KafkaMetadataConverter { + + public static String KAFKA_METADATA_COLUMN_PREFIX = "__kafka_"; + + /** Converter for Kafka topic name. */ + public static class TopicConverter implements CdcMetadataConverter { + private static final long serialVersionUID = 1L; + + @Override + public String read(JsonNode source) { Review Comment: You could push this into CdcMetadataConverter, so that both read() methods default to UnsupportedOperationException. ########## paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/kafka/KafkaMetadataConverter.java: ########## @@ -0,0 +1,181 @@ +/* + * 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.kafka; + +import org.apache.paimon.data.Timestamp; +import org.apache.paimon.flink.action.cdc.CdcMetadataConverter; +import org.apache.paimon.flink.action.cdc.CdcSourceRecord; +import org.apache.paimon.types.DataType; +import org.apache.paimon.types.DataTypes; +import org.apache.paimon.utils.DateTimeUtils; + +import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode; + +import java.util.TimeZone; + +/** + * Kafka-specific implementations of {@link CdcMetadataConverter} for extracting Kafka message + * metadata. + * + * <p>These converters read from the generic metadata map in {@link CdcSourceRecord} to extract + * Kafka-specific metadata like topic, partition, offset, timestamp, and timestamp type. + */ +public class KafkaMetadataConverter { + + public static String KAFKA_METADATA_COLUMN_PREFIX = "__kafka_"; + + /** Converter for Kafka topic name. */ + public static class TopicConverter implements CdcMetadataConverter { + private static final long serialVersionUID = 1L; + + @Override + public String read(JsonNode source) { Review Comment: In fact, you could dedupe most of this by adding a 'fieldName' parameter & pulling all the methods out into a superclass. -- 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]
