amogh-jahagirdar commented on code in PR #11180:
URL: https://github.com/apache/iceberg/pull/11180#discussion_r1797722022


##########
core/src/main/java/org/apache/iceberg/rest/responses/FetchPlanningResultResponseParser.java:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.iceberg.rest.responses;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.util.List;
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.FileScanTask;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.rest.PlanStatus;
+import org.apache.iceberg.rest.RESTContentFileParser;
+import org.apache.iceberg.rest.RESTFileScanTaskParser;
+import org.apache.iceberg.util.JsonUtil;
+
+public class FetchPlanningResultResponseParser {
+  private static final String PLAN_STATUS = "plan-status";
+  private static final String PLAN_TASKS = "plan-tasks";
+  private static final String FILE_SCAN_TASKS = "file-scan-tasks";
+  private static final String DELETE_FILES = "delete-files";
+
+  private FetchPlanningResultResponseParser() {}
+
+  public static String toJson(FetchPlanningResultResponse response) {
+    return toJson(response, false);
+  }
+
+  public static String toJson(FetchPlanningResultResponse response, boolean 
pretty) {
+    return JsonUtil.generate(gen -> toJson(response, gen), pretty);
+  }
+
+  public static void toJson(FetchPlanningResultResponse response, 
JsonGenerator gen)
+      throws IOException {
+    Preconditions.checkArgument(null != response, "Invalid response: 
planTableScanResponse null");
+
+    gen.writeStartObject();
+    if (response.planStatus() != null) {
+      gen.writeStringField(PLAN_STATUS, response.planStatus().status());
+    }
+
+    if (response.planTasks() != null) {
+      gen.writeArrayFieldStart(PLAN_TASKS);
+      for (String planTask : response.planTasks()) {
+        gen.writeString(planTask);
+      }
+      gen.writeEndArray();
+    }
+
+    List<DeleteFile> deleteFiles = null;
+    if (response.deleteFiles() != null) {
+      deleteFiles = response.deleteFiles();
+      gen.writeArrayFieldStart(DELETE_FILES);
+      for (DeleteFile deleteFile : deleteFiles) {
+        RESTContentFileParser.toJson(deleteFile);
+      }
+      gen.writeEndArray();
+    }
+
+    if (response.fileScanTasks() != null) {
+      gen.writeArrayFieldStart(FILE_SCAN_TASKS);
+      for (FileScanTask fileScanTask : response.fileScanTasks()) {
+        RESTFileScanTaskParser.toJson(fileScanTask, deleteFiles, gen);

Review Comment:
   I was looking at this again locally, correction in the second half:
   
   ```
   
       if (response.fileScanTasks() != null) {
         gen.writeArrayFieldStart(FILE_SCAN_TASKS);
         for (FileScanTask fileScanTask : response.fileScanTasks()) {
         // the list should be initialized here, the delete file references are 
per file scan task
         List<Integer> deleteFileReferences = Lists.newArrayList();
   
           if (deleteFiles != null) {
             for (DeleteFile taskDelete : taskDeletes) {
               
deleteFileReferences.add(deleteFilePathToIndex.get(taskDelete.location()));
             }
           }
   
           RESTFileScanTaskParser.toJson(fileScanTask, deleteFileReferences, 
gen);
         }
   ```
   
   Anyways, with tests this will all be made clear 



##########
core/src/main/java/org/apache/iceberg/RESTTable.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.iceberg;
+
+import java.util.Map;
+import java.util.function.Supplier;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.metrics.MetricsReporter;
+import org.apache.iceberg.rest.RESTClient;
+import org.apache.iceberg.rest.ResourcePaths;
+
+public class RESTTable extends BaseTable {

Review Comment:
   I think we'll also need to make sure whatever abstraction we introduce can 
work well with engine integrations. E.g. one open question is if and how this 
should fit in to Spark's Distributed planning model?
   
    I think to begin to keep it simple, we can just say that if remote planning 
is actually a requirement from the server, then we would make sure Spark does 
not do a distributed plan. But I think the model should be flexible though that 
in the future if we wanted to distribute the plan tasks as part of a 
distributed planning we could be able to do so.



-- 
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-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to