You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by dz...@apache.org on 2022/02/20 05:35:34 UTC

[drill] branch master updated: DRILL-8142: SAS Reader Returns NPE #2468

This is an automated email from the ASF dual-hosted git repository.

dzamo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new c0d3e8e   DRILL-8142: SAS Reader Returns NPE #2468
c0d3e8e is described below

commit c0d3e8e11b863d0883b9d9717563970cfbd9ccc5
Author: Charles S. Givre <cg...@apache.org>
AuthorDate: Sun Feb 20 00:35:25 2022 -0500

     DRILL-8142: SAS Reader Returns NPE #2468
---
 .../apache/drill/exec/store/sas/SasBatchReader.java  | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/contrib/format-sas/src/main/java/org/apache/drill/exec/store/sas/SasBatchReader.java b/contrib/format-sas/src/main/java/org/apache/drill/exec/store/sas/SasBatchReader.java
index 187b174..ac6d987 100644
--- a/contrib/format-sas/src/main/java/org/apache/drill/exec/store/sas/SasBatchReader.java
+++ b/contrib/format-sas/src/main/java/org/apache/drill/exec/store/sas/SasBatchReader.java
@@ -167,10 +167,17 @@ public class SasBatchReader implements ManagedReader<FileScanFramework.FileSchem
     for (Column column : columns) {
       String fieldName = column.getName();
       try {
-        MinorType type = getType(firstRow[counter].getClass().getSimpleName());
-        if (type == MinorType.BIGINT && !column.getFormat().isEmpty()) {
-          logger.debug("Found possible time");
-          type = MinorType.TIME;
+        MinorType type = null;
+        if (firstRow[counter] != null) {
+          type = getType(firstRow[counter].getClass().getSimpleName());
+          if (type == MinorType.BIGINT && !column.getFormat().isEmpty()) {
+            logger.debug("Found possible time");
+            type = MinorType.TIME;
+          }
+        } else {
+          // If the first row is null
+          String columnType = column.getType().getSimpleName();
+          type = getType(columnType);
         }
         builder.addNullable(fieldName, type);
       } catch (Exception e) {
@@ -214,6 +221,7 @@ public class SasBatchReader implements ManagedReader<FileScanFramework.FileSchem
     switch (simpleType) {
       case "String":
         return MinorType.VARCHAR;
+      case "Numeric":
       case "Double":
         return MinorType.FLOAT8;
       case "Long":
@@ -357,7 +365,9 @@ public class SasBatchReader implements ManagedReader<FileScanFramework.FileSchem
 
     @Override
     public void load(Object[] row) {
-      writer.setString((String) row[columnIndex]);
+      if (row[columnIndex] != null) {
+        writer.setString((String) row[columnIndex]);
+      }
     }
 
     public void load (String value) {