jerryshao commented on a change in pull request #674: [WIP]Supports spark-3.0 
data source V2 APIs
URL: https://github.com/apache/incubator-iceberg/pull/674#discussion_r353595466
 
 

 ##########
 File path: 
spark/src/main/java/org/apache/iceberg/spark/source/IcebergBatchScan.java
 ##########
 @@ -321,7 +302,160 @@ private Schema lazyExpectedSchema() {
     }
   }
 
-  private static class TaskDataReader implements 
InputPartitionReader<InternalRow> {
+  @Override
+  public InputPartition[] planInputPartitions() {
+    String tableSchemaString = SchemaParser.toJson(table.schema());
+    String expectedSchemaString = SchemaParser.toJson(lazySchema());
+
+    List<CombinedScanTask> scanTasks = tasks();
+    InputPartition[] readTasks = new InputPartition[scanTasks.size()];
+    for (int i = 0; i < scanTasks.size(); i++) {
+      readTasks[i] = new BatchReadInputPartition(scanTasks.get(i), 
tableSchemaString, expectedSchemaString, fileIo,
+          encryptionManager, caseSensitive);
+    }
+
+    return readTasks;
+  }
+
+  @Override
+  public IcebergRowReaderFactory createReaderFactory() {
+    return new IcebergRowReaderFactory();
+  }
+
+  private Schema lazySchema() {
+    if (schema == null) {
+      if (requestedSchema != null) {
+        this.schema = SparkSchemaUtil.prune(table.schema(), requestedSchema);
+      } else {
+        this.schema = table.schema();
+      }
+    }
+    return schema;
+  }
+
+  private StructType lazyType() {
+    if (type == null) {
+      this.type = SparkSchemaUtil.convert(lazySchema());
+    }
+    return type;
+  }
+
+  @Override
+  public StructType readSchema() {
+    return lazyType();
+  }
+
+
 
 Review comment:
   nit: additional line. Is this the required style?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to