leonardBang commented on code in PR #250:
URL: 
https://github.com/apache/flink-connector-kafka/pull/250#discussion_r3234259396


##########
flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/GetKafkaSourceOffsetsTableFunction.java:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.flink.streaming.connectors.kafka.table;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.state.ListState;
+import org.apache.flink.api.common.state.ListStateDescriptor;
+import org.apache.flink.api.common.typeinfo.Types;
+import org.apache.flink.connector.kafka.source.split.KafkaPartitionSplit;
+import 
org.apache.flink.connector.kafka.source.split.KafkaPartitionSplitSerializer;
+import org.apache.flink.core.fs.CloseableRegistry;
+import org.apache.flink.core.memory.DataInputViewStreamWrapper;
+import org.apache.flink.runtime.checkpoint.OperatorState;
+import org.apache.flink.runtime.checkpoint.OperatorSubtaskState;
+import org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadata;
+import org.apache.flink.runtime.state.DefaultOperatorStateBackend;
+import org.apache.flink.runtime.state.DefaultOperatorStateBackendBuilder;
+import org.apache.flink.runtime.state.OperatorStateHandle;
+import org.apache.flink.state.api.OperatorIdentifier;
+import org.apache.flink.state.api.runtime.SavepointLoader;
+import org.apache.flink.table.annotation.DataTypeHint;
+import org.apache.flink.table.annotation.FunctionHint;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.functions.BuiltInFunctionDefinition;
+import org.apache.flink.table.functions.SpecializedFunction;
+import org.apache.flink.table.functions.TableFunction;
+import org.apache.flink.table.types.inference.TypeStrategies;
+import org.apache.flink.types.Row;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.StreamSupport;
+
+import static org.apache.flink.table.functions.FunctionKind.TABLE;
+
+/**
+ * Table function to extract Kafka source offsets from savepoints.
+ *
+ * <p>This function reads Kafka partition splits from a savepoint and extracts 
the offset
+ * information for each partition. The function is designed to work with the 
Flink state processing
+ * API and provides visibility into the Kafka source state.
+ */
+@Internal
+@FunctionHint(
+        output =
+                @DataTypeHint(
+                        "ROW<topic STRING NOT NULL, "
+                                + "partition INT NOT NULL, "
+                                + "starting-offset BIGINT NOT NULL, "
+                                + "stopping-offset BIGINT NULL>"))
+public class GetKafkaSourceOffsetsTableFunction extends TableFunction<Row> {

Review Comment:
   Thanks for ping me @loserwang1024 and thanks for the contribution 
@gaborgsomogyi .
   My quick reply for the two concern:
   1. Regarding the potential function naming conflicts — I think it's fine. 
Any built-in function has the possibility of conflicting with user-defined 
functions. Each connector having its own specific CLI tools or custom functions 
actually has practical value. From a naming perspective, the probability of 
conflict is not high.
   
   2. Naming is a well-known headache in computer science — there's no 
universal rule, and everyone has their own taste. However, from a usability 
standpoint, I'd prefer: `SELECT * FROM 
kafka_offset_in_savepoint('/path/to/savepoint', 'kafka-source-operator-uid')`;
   
   
   
   
   



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