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


##########
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:
   There is a line between custom keyed state and operator states. The first is 
fully custom and may require custom logic during reading while the latter is 
hardcoded into operators (with with some slow changing fashion). Bugging users 
with technical fields where we can avoid that is something where I would vote 
on user experience than technical concerns.
   
   I think this is way more convenient from user perspective:
   ```
   LOAD MODULE state;
   SELECT * FROM savepoint_get_kafka_offsets('/path/to/savepoint', 
'my-kafka-source-uid');
   ```
   We want to bring state closer to users and making it more difficult than it 
could be going to effect how widely we can spread it. As an offtopic even for 
the already available connector we must find more simplifications.
   



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