You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by js...@apache.org on 2015/05/05 03:38:25 UTC

[1/3] drill git commit: DRILL-2533: Use Math.round() instead of casting to long

Repository: drill
Updated Branches:
  refs/heads/master f240ac2a3 -> ac823fe8b


DRILL-2533: Use Math.round() instead of casting to long


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/800dad0c
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/800dad0c
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/800dad0c

Branch: refs/heads/master
Commit: 800dad0c5fcce99090c443726d649b4261c35079
Parents: f240ac2
Author: Sudheesh Katkam <sk...@maprtech.com>
Authored: Mon Apr 13 10:17:14 2015 -0700
Committer: Jason Altekruse <al...@gmail.com>
Committed: Mon May 4 16:32:14 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/exec/server/rest/profile/TableBuilder.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/800dad0c/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/TableBuilder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/TableBuilder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/TableBuilder.java
index e91404f..7d3b322 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/TableBuilder.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/TableBuilder.java
@@ -105,7 +105,7 @@ class TableBuilder {
   }
 
   public void appendNanos(final long p, final String link) {
-    appendMillis((long) (p / 1000.0 / 1000.0), link);
+    appendMillis(Math.round(p / 1000.0 / 1000.0), link);
   }
 
   public void appendFormattedNumber(final Number n, final String link) {


[3/3] drill git commit: DRILL-2221: Do not skip writing an empty list

Posted by js...@apache.org.
DRILL-2221: Do not skip writing an empty list

small fix for bad resolution of merge conflict in free marker template

Fix test to use dfs_test instead of the default dfs storage plugin


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/ac823fe8
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/ac823fe8
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/ac823fe8

Branch: refs/heads/master
Commit: ac823fe8bd9d6b778f37e32d95ab0d199f8ff551
Parents: dcbf461
Author: Sudheesh Katkam <sk...@maprtech.com>
Authored: Fri Apr 10 15:00:41 2015 -0700
Committer: Jason Altekruse <al...@gmail.com>
Committed: Mon May 4 16:33:53 2015 -0700

----------------------------------------------------------------------
 .../main/codegen/templates/JsonOutputRecordWriter.java  |  5 -----
 .../test/java/org/apache/drill/TestExampleQueries.java  | 12 ++++++++++++
 .../resources/store/json/record_with_empty_list.json    |  2 ++
 3 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/ac823fe8/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java b/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
index 1bea326..ea643f0 100644
--- a/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
+++ b/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
@@ -89,13 +89,8 @@ public abstract class JSONOutputRecordWriter extends AbstractRecordWriter implem
     @Override
     public void writeField() throws IOException {
   <#if mode.prefix == "Repeated" >
-    // empty lists are represented by simply not starting a field, rather than starting one and putting in 0 elements
-    if (reader.size() == 0) {
-      return;
-    }
     gen.writeStartArray();
     for (int i = 0; i < reader.size(); i++) {
-  <#else>
   </#if>
   
   <#assign typeName = minor.class >

http://git-wip-us.apache.org/repos/asf/drill/blob/ac823fe8/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
index d5c5385..7e07500 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
@@ -831,4 +831,16 @@ public class TestExampleQueries extends BaseTestQuery{
         .baselineValues("MIDDLE EAST")
         .build().run();
   }
+
+  @Test // DRILL-2221
+  public void createJsonWithEmptyList() throws Exception {
+    final String file = FileUtils.getResourceAsFile("/store/json/record_with_empty_list.json").toURI().toString();
+    final String tableName = "jsonWithEmptyList";
+    test("USE dfs_test.tmp");
+    test("ALTER SESSION SET `store.format`='json'");
+    test(String.format("CREATE TABLE %s AS SELECT * FROM `%s`", tableName, file));
+    test(String.format("SELECT COUNT(*) FROM %s", tableName));
+    test("ALTER SESSION SET `store.format`='parquet'");
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/ac823fe8/exec/java-exec/src/test/resources/store/json/record_with_empty_list.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/store/json/record_with_empty_list.json b/exec/java-exec/src/test/resources/store/json/record_with_empty_list.json
new file mode 100644
index 0000000..4338365
--- /dev/null
+++ b/exec/java-exec/src/test/resources/store/json/record_with_empty_list.json
@@ -0,0 +1,2 @@
+{ "a": "A1", "b": [ "B1", "B2" ], "c": [ "C1", "C2" ] }
+{ "a": "A2", "b": [ "B3" ], "c": [] }
\ No newline at end of file


[2/3] drill git commit: DRILL-1827: Unit test framework fix, expected and actual results were flipped in unordered comparison error message.

Posted by js...@apache.org.
DRILL-1827: Unit test framework fix, expected and actual results were flipped in unordered comparison error message.

Small fix to expected message in unit test framework tests.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/dcbf4619
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/dcbf4619
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/dcbf4619

Branch: refs/heads/master
Commit: dcbf46194775b01031e817b715dfed98b8be5c3e
Parents: 800dad0
Author: Jason Altekruse <al...@gmail.com>
Authored: Mon Dec 8 15:55:00 2014 -0800
Committer: Jason Altekruse <al...@gmail.com>
Committed: Mon May 4 16:32:27 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/drill/DrillTestWrapper.java | 61 +++++++++++---------
 .../org/apache/drill/TestFrameworkTest.java     |  2 +-
 2 files changed, 36 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/dcbf4619/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java b/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
index d05c896..856dfa5 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
@@ -37,6 +37,7 @@ import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -267,28 +268,32 @@ public class DrillTestWrapper {
     RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
     BatchSchema schema = null;
 
-    BaseTestQuery.test(testOptionSettingQueries);
-    List<QueryDataBatch> expected = BaseTestQuery.testRunAndReturn(queryType, query);
+    List<QueryDataBatch> actual = Collections.EMPTY_LIST;;
+    List<QueryDataBatch> expected = Collections.EMPTY_LIST;
+    List<Map> expectedRecords = new ArrayList<>();
+    List<Map> actualRecords = new ArrayList<>();
 
-    addTypeInfoIfMissing(expected.get(0), testBuilder);
+    try {
+      BaseTestQuery.test(testOptionSettingQueries);
+      actual = BaseTestQuery.testRunAndReturn(queryType, query);
 
-    List<Map> expectedRecords = new ArrayList<>();
-    addToMaterializedResults(expectedRecords, expected, loader, schema);
+      addTypeInfoIfMissing(actual.get(0), testBuilder);
+      addToMaterializedResults(actualRecords, actual, loader, schema);
 
-    List<QueryDataBatch> results = new ArrayList();
-    List<Map> actualRecords = new ArrayList<>();
-    // If baseline data was not provided to the test builder directly, we must run a query for the baseline, this includes
-    // the cases where the baseline is stored in a file.
-    if (baselineRecords == null) {
-      BaseTestQuery.test(baselineOptionSettingQueries);
-      results = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
-      addToMaterializedResults(actualRecords, results, loader, schema);
-    } else {
-      actualRecords = baselineRecords;
-    }
+      // If baseline data was not provided to the test builder directly, we must run a query for the baseline, this includes
+      // the cases where the baseline is stored in a file.
+      if (baselineRecords == null) {
+        BaseTestQuery.test(baselineOptionSettingQueries);
+        expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
+        addToMaterializedResults(expectedRecords, expected, loader, schema);
+      } else {
+        expectedRecords = baselineRecords;
+      }
 
-    compareResults(expectedRecords, actualRecords);
-    cleanupBatches(expected, results);
+      compareResults(expectedRecords, actualRecords);
+    } finally {
+      cleanupBatches(actual, expected);
+    }
   }
 
   /**
@@ -312,15 +317,18 @@ public class DrillTestWrapper {
     RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
     BatchSchema schema = null;
 
+    List<QueryDataBatch> actual = Collections.EMPTY_LIST;;
+    List<QueryDataBatch> expected = Collections.EMPTY_LIST;
+    Map<String, List> actualSuperVectors;
+    Map<String, List> expectedSuperVectors;
+
+    try {
     BaseTestQuery.test(testOptionSettingQueries);
-    List<QueryDataBatch> results = BaseTestQuery.testRunAndReturn(queryType, query);
+    actual = BaseTestQuery.testRunAndReturn(queryType, query);
     // To avoid extra work for test writers, types can optionally be inferred from the test query
-    addTypeInfoIfMissing(results.get(0), testBuilder);
-
-    Map<String, List> actualSuperVectors = addToCombinedVectorResults(results, loader, schema);
+    addTypeInfoIfMissing(actual.get(0), testBuilder);
 
-    List<QueryDataBatch> expected = null;
-    Map<String, List> expectedSuperVectors = null;
+    actualSuperVectors = addToCombinedVectorResults(actual, loader, schema);
 
     // If baseline data was not provided to the test builder directly, we must run a query for the baseline, this includes
     // the cases where the baseline is stored in a file.
@@ -344,8 +352,9 @@ public class DrillTestWrapper {
     }
 
     compareMergedVectors(expectedSuperVectors, actualSuperVectors);
-
-    cleanupBatches(expected, results);
+    } finally {
+      cleanupBatches(expected, actual);
+    }
   }
 
   public void compareResultsHyperVector() throws Exception {

http://git-wip-us.apache.org/repos/asf/drill/blob/dcbf4619/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java b/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
index 3abd193..31a7a64 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
@@ -337,7 +337,7 @@ public class TestFrameworkTest extends BaseTestQuery{
           .expectsEmptyResultSet()
           .build().run();
     } catch (AssertionError ex) {
-      assertEquals("Different number of records returned expected:<4> but was:<0>", ex.getMessage());
+      assertEquals("Different number of records returned expected:<0> but was:<4>", ex.getMessage());
       // this indicates successful completion of the test
       return;
     }