private void createAndQuery(String datafile) throws Exception { String query = String.format("select * from cp.\"parquet/%s\"", datafile); String tableName = "test_repeated_readers_"+datafile; try { test("create table dfs_test.\"%s\" as %s", tableName, query); testBuilder() .sqlQuery("select * from dfs_test.\"%s\" d", tableName) .ordered() .jsonBaselineFile("parquet/" + datafile) .go(); } finally { deleteTableIfExists(tableName); } }
@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 "+ ""; test("alter session set \"exec.enable_union_type\"=true"); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("complex/drill-1649-result.json") .go(); test("alter session set \"exec.enable_union_type\"=false"); }
@Test //DRILL-1832 @Ignore public void testJsonWithNulls2() throws Exception { final String query="select SUM(1) as \"sum_Number_of_Records_ok\" from cp.\"/jsoninput/twitter_43.json\" having (COUNT(1) > 0)"; testBuilder() .sqlQuery(query) .ordered() .jsonBaselineFile("jsoninput/drill-1832-2-result.json") .go(); }
@Test //DRILL-1832 @Ignore("update baseline") public void testJsonWithNulls1() throws Exception { final String query="select * from cp.\"jsoninput/twitter_43.json\""; testBuilder() .sqlQuery(query) .ordered() .jsonBaselineFile("jsoninput/drill-1832-1-result.json") .go(); }
@Test //DRILL-2268 public void testFlattenAfterJoin3() throws Exception { String query = "select flatten(sub1.lst_lst) flat_lst_lst from "+ "(select t1.lst_lst lst_lst from cp.\"complex/json/flatten_join.json\" t1 "+ "inner join cp.\"complex/json/flatten_join.json\" t2 on t1.id=t2.id) sub1"; testPlanSubstrPatterns(query, new String[] {"columns=[`id`, `lst_lst`]", "columns=[`id`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("complex/drill-2268-3-result.json") .go(); }
@Test //DRILL-2268 public void testFlattenAfterJoin1() throws Exception { String query = "select flatten(sub1.events) flat_events from "+ "(select t1.events events from cp.\"complex/json/flatten_join.json\" t1 "+ "inner join cp.\"complex/json/flatten_join.json\" t2 on t1.id=t2.id) sub1"; testPlanSubstrPatterns(query, new String[] {"columns=[`id`, `events`]", "columns=[`id`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("complex/drill-2268-1-result.json") .go(); }
@Test public void testDRILL_2106_2() throws Exception { String query = "select rl, flatten(rl) frl from (select flatten(rl) as rl, \"integer\" from cp.\"jsoninput/input2.json\")"; testPlanSubstrPatterns(query, new String[] {"columns=[`rl`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("flatten/drill-2106-result.json") .go(); }
@Test public void testDRILL_2106() throws Exception { String query = "select rl, flatten(rl) frl from (select \"integer\", flatten(rl) as rl from cp.\"jsoninput/input2.json\")"; testPlanSubstrPatterns(query, new String[] {"columns=[`rl`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("flatten/drill-2106-result.json") .go(); }
@Test //DRILL-1962 public void testProjectionMultipleFiles() throws Exception { final String query="select t.oooa.oa.oab.oabc[1].rowValue1 rowValue from dfs.\"${WORKING_PATH}/src/test/resources/complex/json/multiple/*.json\" t"; testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("complex/drill-1962-result.json") .go(); }
@Test //DRILL-2268 public void testFlattenAfterJoin2() throws Exception { String query = "select flatten(t1.events) flat_events from cp.\"complex/json/flatten_join.json\" t1 " + "inner join cp.\"complex/json/flatten_join.json\" t2 on t1.id=t2.id"; testPlanSubstrPatterns(query, new String[] {"columns=[`id`, `events`]", "columns=[`id`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("complex/drill-2268-2-result.json") .go(); }
@Test //DRILL-2099 public void testFlattenAfterSort() throws Exception { String query = "select flatten(s1.rms.rptd) rptds from " + "(select d.uid uid, flatten(d.map.rm) rms from cp.\"jsoninput/flatten_post_sort.json\" d order by d.uid) s1"; testPlanSubstrPatterns(query, new String[] {"columns=[`uid`, `map`.`rm`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("flatten/drill-2099-result.json") .go(); }