drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [3/3] drill git commit: DRILL-1649: Added unit tests
Date Wed, 01 Apr 2015 18:41:20 GMT
DRILL-1649: Added unit tests


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

Branch: refs/heads/master
Commit: 767711919f087d72fb94d2b94823b9ae0af660db
Parents: fb4533f
Author: Parth Chandra <pchandra@maprtech.com>
Authored: Tue Mar 31 16:55:45 2015 -0700
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Wed Apr 1 11:41:01 2015 -0700

----------------------------------------------------------------------
 .../exec/nested/TestNestedComplexSchema.java    | 29 ++++++++++++++++++++
 .../resources/complex/drill-1649-result.json    |  2 ++
 .../complex/json/single-user-transactions.json  | 18 ++++++++++++
 3 files changed, 49 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/76771191/exec/java-exec/src/test/java/org/apache/drill/exec/nested/TestNestedComplexSchema.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/nested/TestNestedComplexSchema.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/nested/TestNestedComplexSchema.java
index 1865120..05a5308 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/nested/TestNestedComplexSchema.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/nested/TestNestedComplexSchema.java
@@ -37,4 +37,33 @@ public class TestNestedComplexSchema extends BaseTestQuery {
     test("select tbl.a.arrayval[0].val1[0] from cp.`nested/nested_3.json` tbl");
   }
 
+  @Test //DRILL-1649
+  public void testNestedFlattenWithJoin() throws Exception {
+
+    final String query="" +
+    "  select event_info.uid, transaction_info.trans_id, event_info.event.evnt_id  evnt_id
"+
+    "from ( "+
+    "  select userinfo.transaction.trans_id trans_id, max(userinfo.event.event_time) max_event_time
"+
+    "  from ( "+
+      "    select uid, flatten(events) event, flatten(transactions) transaction from cp.`complex/json/single-user-transactions.json`
"+
+    ") userinfo "+
+    "where userinfo.transaction.trans_time >= userinfo.event.event_time "+
+    "group by userinfo.transaction.trans_id "+
+    ") transaction_info "+
+    "inner join "+
+    "( "+
+    "  select uid, flatten(events) event "+
+    "  from cp.`complex/json/single-user-transactions.json` "+
+    ") event_info "+
+    "on transaction_info.max_event_time = event_info.event.event_time "+
+    "";
+
+    testBuilder()
+      .sqlQuery(query)
+      .unOrdered()
+      .jsonBaselineFile("complex/drill-1649-result.json")
+      .go();
+  }
+
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/76771191/exec/java-exec/src/test/resources/complex/drill-1649-result.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/complex/drill-1649-result.json b/exec/java-exec/src/test/resources/complex/drill-1649-result.json
new file mode 100644
index 0000000..3add8d5
--- /dev/null
+++ b/exec/java-exec/src/test/resources/complex/drill-1649-result.json
@@ -0,0 +1,2 @@
+{"uid":1,"trans_id":"t1","evnt_id":"e7"}
+{"uid":1,"trans_id":"t2","evnt_id":"e8"}

http://git-wip-us.apache.org/repos/asf/drill/blob/76771191/exec/java-exec/src/test/resources/complex/json/single-user-transactions.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/complex/json/single-user-transactions.json
b/exec/java-exec/src/test/resources/complex/json/single-user-transactions.json
new file mode 100644
index 0000000..cff5532
--- /dev/null
+++ b/exec/java-exec/src/test/resources/complex/json/single-user-transactions.json
@@ -0,0 +1,18 @@
+{
+    "uid" : 1,
+    "events" : [
+        { "evnt_id":"e1", "campaign_id":"c1", "event_name":"e1_name", "event_time":1000000},
+        { "evnt_id":"e2", "campaign_id":"c1", "event_name":"e2_name", "event_time":2000000},
+        { "evnt_id":"e3", "campaign_id":"c1", "event_name":"e3_name", "event_time":3000000},
+        { "evnt_id":"e4", "campaign_id":"c1", "event_name":"e4_name", "event_time":4000000},
+        { "evnt_id":"e5", "campaign_id":"c2", "event_name":"e5_name", "event_time":5000000},
+        { "evnt_id":"e6", "campaign_id":"c1", "event_name":"e6_name", "event_time":6000000},
+        { "evnt_id":"e7", "campaign_id":"c1", "event_name":"e7_name", "event_time":7000000},
+        { "evnt_id":"e8", "campaign_id":"c2", "event_name":"e8_name", "event_time":8000000},
+        { "evnt_id":"e9", "campaign_id":"c2", "event_name":"e9_name", "event_time":9000000}
+    ],
+   "transactions" : [
+        { "trans_id":"t1", "amount":100, "trans_time":7777777},
+        { "trans_id":"t2", "amount":100, "trans_time":8888888}
+    ]
+}


Mime
View raw message