Copilot commented on code in PR #9223:
URL: https://github.com/apache/seatunnel/pull/9223#discussion_r2057857297


##########
seatunnel-connectors-v2/connector-deltalake/src/main/java/org/apache/seatunnel/connectors/seatunnel/deltalake/source/enumerator/AbstractSplitEnumerator.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.deltalake.source.enumerator;
+
+import io.delta.kernel.Table;
+import io.delta.kernel.engine.Engine;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.seatunnel.api.source.SourceSplitEnumerator;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import 
org.apache.seatunnel.connectors.seatunnel.deltalake.DeltaLakeCatalogLoader;
+import 
org.apache.seatunnel.connectors.seatunnel.deltalake.config.DeltaLakeSourceConfig;
+import 
org.apache.seatunnel.connectors.seatunnel.deltalake.source.split.DeltaLakeFileScanTaskSplit;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+@Slf4j
+public abstract class AbstractSplitEnumerator
+        implements SourceSplitEnumerator<DeltaLakeFileScanTaskSplit, 
DeltaLakeSplitEnumeratorState> {
+
+    protected final Context<DeltaLakeFileScanTaskSplit> context;
+    protected final DeltaLakeSourceConfig sourceConfig;
+    protected final Map<TablePath, CatalogTable> tables;
+    protected final Object stateLock = new Object();
+
+    protected final BlockingQueue<TablePath> pendingTables;
+    protected final Map<Integer, List<DeltaLakeFileScanTaskSplit>> 
pendingSplits;
+
+    public AbstractSplitEnumerator(
+            Context<DeltaLakeFileScanTaskSplit> context,
+            DeltaLakeSourceConfig sourceConfig,
+            Map<TablePath, CatalogTable> catalogTables,
+            Engine engine) {
+        this(context, sourceConfig, catalogTables, engine, null);
+    }
+
+    public AbstractSplitEnumerator(
+            Context<DeltaLakeFileScanTaskSplit> context,
+            DeltaLakeSourceConfig sourceConfig,
+            Map<TablePath, CatalogTable> catalogTables,
+            Engine engine,
+            DeltaLakeSplitEnumeratorState state) {
+        this.context = context;
+        this.sourceConfig = sourceConfig;
+        this.tables = catalogTables;
+        this.pendingTables = new ArrayBlockingQueue<>(catalogTables.size());
+        this.pendingSplits = new HashMap<>();
+        if (state == null) {
+            this.pendingTables.addAll(
+                    catalogTables.values().stream()
+                            .map(CatalogTable::getTablePath)
+                            .collect(Collectors.toList()));
+        } else {
+            this.pendingTables.addAll(state.getPendingTables());
+            state.getPendingSplits().values().stream()
+                    .flatMap(
+                            (Function<
+                                            List<DeltaLakeFileScanTaskSplit>,
+                                            
Stream<DeltaLakeFileScanTaskSplit>>)
+                                    splits -> splits.stream())
+                    .map(
+                            (Function<DeltaLakeFileScanTaskSplit, 
DeltaLakeFileScanTaskSplit>)
+                                    split -> {
+                                        // TODO: Waiting for old version 
migration to complete
+                                        // before remove
+                                        if (split.getTablePath() == null) {
+                                            new DeltaLakeFileScanTaskSplit(

Review Comment:
   Inside the lambda, a new DeltaLakeFileScanTaskSplit is constructed when 
split.getTablePath() is null, but the new instance is never returned, resulting 
in a null value. Consider returning the newly created split instead of always 
returning null.
   ```suggestion
                                               return new 
DeltaLakeFileScanTaskSplit(
   ```



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