From 9d3a92b963271897565cfd81098050b702fcdac5 Mon Sep 17 00:00:00 2001 From: Vitalii Diravka Date: Tue, 26 Sep 2017 04:06:45 -0700 Subject: [PATCH] DRILL-5792: CONVERT_FROM_JSON on an empty file throws runtime exception --- .../src/main/codegen/templates/TypeHelper.java | 1 + exec/jdbc/pom.xml | 1 + .../org/apache/drill/jdbc/test/TestJdbcQuery.java | 11 +++++++++-- exec/jdbc/src/test/resources/empty.csv | 0 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 exec/jdbc/src/test/resources/empty.csv diff --git a/exec/java-exec/src/main/codegen/templates/TypeHelper.java b/exec/java-exec/src/main/codegen/templates/TypeHelper.java index 5ccda852303..e4c8f33193a 100644 --- a/exec/java-exec/src/main/codegen/templates/TypeHelper.java +++ b/exec/java-exec/src/main/codegen/templates/TypeHelper.java @@ -61,6 +61,7 @@ public static SqlAccessor getSqlAccessor(ValueVector vector){ case MAP: case LIST: + case NULL: return new GenericAccessor(vector); } throw new UnsupportedOperationException(buildErrorMessage("find sql accessor", type)); diff --git a/exec/jdbc/pom.xml b/exec/jdbc/pom.xml index c3c48fa5500..71862f6b206 100644 --- a/exec/jdbc/pom.xml +++ b/exec/jdbc/pom.xml @@ -119,6 +119,7 @@ **/.checkstyle **/.buildpath **/*.json + **/*.csv **/*.iml **/git.properties **/donuts-output-data.txt diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java index 1dd172f41b9..894e06f037e 100644 --- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java +++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java @@ -370,7 +370,7 @@ public void testTimeIntervalAddOverflow() throws Exception { @Test // DRILL-1051 public void testOldDateTimeJulianCalendar() throws Exception { - // Should be work with any timezone + // Should work with any timezone JdbcAssert.withNoDefaultSchema() .sql("select cast(to_timestamp('1581-12-01 23:32:01', 'yyyy-MM-dd HH:mm:ss') as date) as `DATE`, " + "to_timestamp('1581-12-01 23:32:01', 'yyyy-MM-dd HH:mm:ss') as `TIMESTAMP`, " + @@ -381,7 +381,7 @@ public void testOldDateTimeJulianCalendar() throws Exception { @Test // DRILL-1051 public void testOldDateTimeLocalMeanTime() throws Exception { - // Should be work with any timezone + // Should work with any timezone JdbcAssert.withNoDefaultSchema() .sql("select cast(to_timestamp('1883-11-16 01:32:01', 'yyyy-MM-dd HH:mm:ss') as date) as `DATE`, " + "to_timestamp('1883-11-16 01:32:01', 'yyyy-MM-dd HH:mm:ss') as `TIMESTAMP`, " + @@ -390,4 +390,11 @@ public void testOldDateTimeLocalMeanTime() throws Exception { .returns("DATE=1883-11-16; TIMESTAMP=1883-11-16 01:32:01.0; TIME=01:32:01"); } + @Test // DRILL-5792 + public void testConvertFromInEmptyInputSql() throws Exception { + JdbcAssert.withNoDefaultSchema() + .sql("SELECT CONVERT_FROM(columns[1], 'JSON') as col1 from cp.`empty.csv`") + .returns(""); + } + } diff --git a/exec/jdbc/src/test/resources/empty.csv b/exec/jdbc/src/test/resources/empty.csv new file mode 100644 index 00000000000..e69de29bb2d