You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2021/10/31 08:44:02 UTC

[GitHub] [drill] luocooong commented on a change in pull request #2354: DRILL-8022: Add Provided Schema Support for Excel Reader

luocooong commented on a change in pull request #2354:
URL: https://github.com/apache/drill/pull/2354#discussion_r739776980



##########
File path: contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -710,6 +785,40 @@ public void load(Cell cell) {
     }
   }
 
+
+  public static class IntStringWriter extends ExcelBatchReader.CellWriter {
+    IntStringWriter(ScalarWriter columnWriter) {
+      super(columnWriter);
+    }
+
+    @Override
+    public void load(Cell cell) {
+      if (cell == null) {
+        columnWriter.setNull();
+      } else {
+        String fieldValue = String.valueOf(cell.getNumericCellValue());
+        columnWriter.setString(fieldValue);
+      }
+    }
+  }
+
+  public static class IntCellWriter extends ExcelBatchReader.CellWriter {
+    IntCellWriter(ScalarWriter columnWriter) {
+      super(columnWriter);
+    }
+
+    @Override
+    public void load(Cell cell) {
+      if (cell == null) {
+        columnWriter.setNull();
+      } else {
+        int fieldNumValue = (int)cell.getNumericCellValue();

Review comment:
       Add a space before `cell`.

##########
File path: contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelBatchReader.java
##########
@@ -363,6 +407,22 @@ private void setFirstRow() {
     }
   }
 
+  /**
+   * This function is used to set the iterator to the first row of actual data.  When a schema is provided,
+   * we can safely skip the header row, and start reading the first row of data.
+   */
+  private void setFirstDataRow() {
+    // Initialize
+    currentRow = rowIterator.next();

Review comment:
       Is it possible to do this (?) : 
   ```java
   // 1. Remove this line
   // 2. Add a loop once
   for (int i = 0; i <= rowNumber + 1; i++) {
     currentRow = rowIterator.next();
   }
   ```




-- 
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: dev-unsubscribe@drill.apache.org

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