Repository: incubator-drill Updated Branches: refs/heads/master 730950622 -> 2871c3ba5
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java b/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java index 3a195e8..e673230 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java +++ b/exec/java-exec/src/test/java/org/apache/drill/PlanningBase.java @@ -115,7 +115,7 @@ public class PlanningBase extends ExecTest{ context.getActiveEndpoints(); result = ImmutableList.of(DrillbitEndpoint.getDefaultInstance()); context.getPlannerSettings(); - result = new PlannerSettings(queryOptions); + result = new PlannerSettings(queryOptions, functionRegistry); context.getOptions(); result = queryOptions; context.getConfig(); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/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 ff7ba44..7c7800d 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 @@ -32,6 +32,18 @@ public class TestExampleQueries extends BaseTestQuery{ test("select recipe, c.inventor.name as name, c.inventor.age as age from cp.`parquet/complex.parquet` c"); } + @Test + public void testFlatten() throws Exception { + test("select flatten(kvgen(f1)) as monkey, x " + + "from cp.`/store/json/test_flatten_mapify.json`"); + + test("select t2.key from (select t.monkey.`value` as val, t.monkey.key as key from (select flatten(kvgen(f1)) as monkey, x " + + "from cp.`/store/json/test_flatten_mapify.json`) as t) as t2 where t2.val > 1"); + + test("select `integer`, `float`, x, flatten(z), flatten(l) from cp.`/jsoninput/input2_modified.json`"); + + } + @Test // see DRILL-553 public void testQueryWithNullValues() throws Exception { test("select count(*) from cp.`customer.json` limit 1"); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/exec/java-exec/src/test/resources/flatten/corrected_physical.json ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/resources/flatten/corrected_physical.json b/exec/java-exec/src/test/resources/flatten/corrected_physical.json new file mode 100644 index 0000000..589e9cd --- /dev/null +++ b/exec/java-exec/src/test/resources/flatten/corrected_physical.json @@ -0,0 +1,81 @@ +{ + "head" : { + "version" : 1, + "generator" : { + "type" : "DefaultSqlHandler", + "info" : "" + }, + "type" : "APACHE_DRILL_PHYSICAL", + "options" : [ { + "name" : "planner.width.max_per_node", + "kind" : "LONG", + "type" : "SESSION", + "num_val" : 2 + } ], + "queue" : 0, + "resultMode" : "EXEC" + }, + "graph" : [ { + "pop" : "fs-scan", + "@id" : 6, + "files" : [ "/jsoninput/input2_modified.json" ], + "storage" : { + "type" : "file", + "enabled" : true, + "connection" : "classpath:///", + "workspaces" : null, + "formats" : { + "csv" : { + "type" : "text", + "extensions" : [ "csv" ], + "delimiter" : "," + }, + "json" : { + "type" : "json" + }, + "parquet" : { + "type" : "parquet" + } + } + }, + "format" : { + "type" : "json" + }, + "columns" : [ "`integer`", "`float`", "`x`", "`z`", "`l`" ], + "selectionRoot" : "/jsoninput/input2_modified.json", + "cost" : 36.0 + }, { + "pop" : "project", + "@id" : 5, + "exprs" : [ { + "ref" : "`EXPR$0`", + "expr" : "`integer`" + }, { + "ref" : "`EXPR$1`", + "expr" : "`x`" + }, { + "ref" : "`EXPR$2`", + "expr" : "z" + }, { + "ref" : "`EXPR$3`", + "expr" : "`l`" + }, { + "ref" : "`EXPR$4`", + "expr" : "`float`" + }, { + "ref" : "`EXPR$5`", + "expr" : "`z`" + } ], + "child" : 6, + "initialAllocation" : 1000000, + "maxAllocation" : 10000000000, + "cost" : 36.0 + }, { + "pop" : "screen", + "@id" : 0, + "child" : 5, + "initialAllocation" : 1000000, + "maxAllocation" : 10000000000, + "cost" : 36.0 + } ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/exec/java-exec/src/test/resources/flatten/test_flatten_physical.json ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/resources/flatten/test_flatten_physical.json b/exec/java-exec/src/test/resources/flatten/test_flatten_physical.json new file mode 100644 index 0000000..c84396d --- /dev/null +++ b/exec/java-exec/src/test/resources/flatten/test_flatten_physical.json @@ -0,0 +1,78 @@ +{ + "head" : { + "version" : 1, + "generator" : { + "type" : "DefaultSqlHandler", + "info" : "" + }, + "type" : "APACHE_DRILL_PHYSICAL", + "options" : [ ], + "queue" : 0, + "resultMode" : "EXEC" + }, + "graph" : [ { + "pop" : "fs-scan", + "@id" : 3, + "files" : [ "/jsoninput/input2_modified.json" ], + "storage" : { + "type" : "file", + "enabled" : true, + "connection" : "classpath:///", + "workspaces" : null, + "formats" : { + "csv" : { + "type" : "text", + "extensions" : [ "csv" ], + "delimiter" : "," + }, + "json" : { + "type" : "json" + }, + "parquet" : { + "type" : "parquet" + } + } + }, + "format" : { + "type" : "json" + }, + "columns" : [ "`integer`", "`float`", "`x`", "`l`" ], + "selectionRoot" : "/jsoninput/input2_modified.json", + "cost" : 0.0 + }, { + "pop" : "project", + "@id" : 2, + "exprs" : [ { + "ref" : "`integer`", + "expr" : "`integer`" + }, { + "ref" : "`float`", + "expr" : "`float`" + }, { + "ref" : "`x`", + "expr" : "`x`" + }, { + "ref" : "`EXPR$3`", + "expr" : "`l`" + } ], + "child" : 3, + "initialAllocation" : 1000000, + "maxAllocation" : 10000000000, + "cost" : 1.0 + }, { + "pop" : "flatten", + "@id" : 1, + "child" : 2, + "initialAllocation" : 1000000, + "maxAllocation" : 10000000000, + "cost" : 1.0, + "column" : "`EXPR$3`" + }, { + "pop" : "screen", + "@id" : 0, + "child" : 1, + "initialAllocation" : 1000000, + "maxAllocation" : 10000000000, + "cost" : 1.0 + } ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/exec/java-exec/src/test/resources/jsoninput/input2_modified.json ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/resources/jsoninput/input2_modified.json b/exec/java-exec/src/test/resources/jsoninput/input2_modified.json new file mode 100644 index 0000000..e24015e --- /dev/null +++ b/exec/java-exec/src/test/resources/jsoninput/input2_modified.json @@ -0,0 +1,106 @@ +{ "integer" : 2010, + "float" : 17.4, + "x": { + "y": "kevin", + "z": "paul" + }, + "z": [ + {"1" : "a" }, + {"2" : "b" }, + {"3" : "c" }, + {"4" : "d" }, + {"5" : "e" }, + {"6" : "f" }, + {"7" : "g" }, + {"8" : "g" }, + {"9" : "i" }, + {"10" : "j"} + ], + "l": [4,2], + "rl": [ [2,1], [4,6] ] +} +{ "integer" : 2001, + "float" : 1.2, + "x": { + "y": "bill", + "z": "peter" + }, + "z": [ + {"pink" : "lilac" } + ], + "l": [4,2], + "rl": [ [3,1], [9,7] ], + "l2" : [ "456", "qwerty", "meh", "trogdor" ] +} +{ "integer" : 6005, + "float" : 1.2, + "x": { + "y": "mike", + "z": "mary" + }, + "z": [ + {"1" : "a" }, + {"2" : "b" }, + {"3" : "c" }, + {"4" : "d" }, + {"5" : "e" }, + {"6" : "f" }, + {"7" : "g" }, + {"8" : "g" }, + {"9" : "i" }, + {"10" : "j" } + ], + "l2" : [ "123", "asd", "abc", "lkh" ], + "l": [ + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9, 9999999], + "rl": [ [7,1], [4,1], [], [1,2,3,4], + [7,1], [4,1], [], [1,2,3,4], + [7,1], [4,1], [], [1,2,3,4], + [7,1], [4,1], [], [1,2,3,4] + ] +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/exec/java-exec/src/test/resources/jsoninput/repeated_list_bug.json ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/resources/jsoninput/repeated_list_bug.json b/exec/java-exec/src/test/resources/jsoninput/repeated_list_bug.json new file mode 100644 index 0000000..1f322d5 --- /dev/null +++ b/exec/java-exec/src/test/resources/jsoninput/repeated_list_bug.json @@ -0,0 +1,6 @@ +{ + "rl" : [ [4,6], [2,3] ] +} +{ + "rl" : [ [9,7], [4,8] ] +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/exec/java-exec/src/test/resources/store/json/nested_json.json ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/resources/store/json/nested_json.json b/exec/java-exec/src/test/resources/store/json/nested_json.json new file mode 100644 index 0000000..421318c --- /dev/null +++ b/exec/java-exec/src/test/resources/store/json/nested_json.json @@ -0,0 +1,8 @@ +{ + "f_1" : 5, + "nested_json" : "{ \"f_2\" : [1,2,3] }" +} +{ + "f_1" : 5, + "nested_json" : "{ \"f_2\" : [10,9,8] }" +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2871c3ba/exec/java-exec/src/test/resources/store/json/test_flatten_mapify.json ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/resources/store/json/test_flatten_mapify.json b/exec/java-exec/src/test/resources/store/json/test_flatten_mapify.json new file mode 100644 index 0000000..7c7fb93 --- /dev/null +++ b/exec/java-exec/src/test/resources/store/json/test_flatten_mapify.json @@ -0,0 +1,26 @@ +{ + "f1" : { "col_1" : 1, + "col_2" : 2, + "col_3" : 3, + "col_4" : 4 + }, + "x" : 1 +} +{ + "f1" : { "col_1" : 1, + "col_2" : 2, + "col_3" : 3, + "col_4" : 4 + }, + "x" : 2 +} +{ + "f1" : { "col_7" : 7, + "col_8" : 8, + "col_9" : 9, + "col_0" : 0 + }, + "x" : 2 +} + "x" : 1 +}