@Test public void sort() throws Exception { String query = String.format("select * from %s order by amount", DATAFILE); testBuilder() .sqlQuery(query) .ordered() .jsonBaselineFile("store/parquet/complex/baseline_sorted.json") .build() .run(); }
@Test public void secondElementInMap() throws Exception { String query = String.format("select t.\"marketing_info\".keywords as keywords from %s t", DATAFILE); String[] columns = {"keywords"}; testBuilder() .sqlQuery(query) .ordered() .jsonBaselineFile("store/parquet/complex/baseline3.json") .baselineColumns(columns) .build() .run(); }
@Test public void elementsOfArray() throws Exception { String query = String.format("select t.\"marketing_info\".keywords[0] as keyword0, t.\"marketing_info\".keywords[2] as keyword2 from %s t", DATAFILE); String[] columns = {"keyword0", "keyword2"}; testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("store/parquet/complex/baseline4.json") .baselineColumns(columns) .build() .run(); }
@Test public void elementsOfArrayCaseInsensitive() throws Exception { String query = String.format("select t.\"MARKETING_INFO\".keywords[0] as keyword0, t.\"Marketing_Info\".Keywords[2] as keyword2 from %s t", DATAFILE); String[] columns = {"keyword0", "keyword2"}; testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("store/parquet/complex/baseline4.json") .baselineColumns(columns) .build() .run(); }
@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-3533 @Ignore("json null type") public void notxistsField() throws Exception { String query = String.format("select t.\"marketing_info\".notexists as notexists, t.\"marketing_info\".camp_id as id from %s t", DATAFILE); String[] columns = {"notexists", "id"}; testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("store/parquet/complex/baseline8.json") .baselineColumns(columns) .build() .run(); }
@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 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 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 selectMultiElements() throws Exception { String query = "select t.marketing_info.camp_id as camp_id, t.marketing_info.keywords as keywords from cp.\"store/parquet/complex/complex.parquet\" t"; testBuilder() .sqlQuery(query) .ordered() .jsonBaselineFile("store/parquet/complex/baseline7.json") .build() .run(); }
@Test public void testMapOrdering() throws Exception { testBuilder() .sqlQuery("select * from cp.\"/testframework/map_reordering.json\"") .unOrdered() .jsonBaselineFile("testframework/map_reordering2.json") .build().run(); }
@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(); }
@Test public void selectMapAndElements() throws Exception { String query = "select marketing_info, t.marketing_info.camp_id as camp_id, t.marketing_info.keywords[2] as keyword2 from cp.\"store/parquet/complex/complex.parquet\" t"; testBuilder() .sqlQuery(query) .ordered() .jsonBaselineFile("store/parquet/complex/baseline6.json") .build() .run(); }
@Test public void testStar() throws Exception { testBuilder() .sqlQuery("select * from cp.\"store/parquet/complex/complex.parquet\"") .ordered() .jsonBaselineFile("store/parquet/complex/baseline.json") .build() .run(); }
@Test //DRILL-2254 supplementary public void testSingleMultiFlattenFromNestedRepeatedList() throws Exception { final String query = "select t.uid, flatten(t.odd) once, flatten(flatten(t.odd)) twice from cp.\"project/complex/a.json\" t"; testPlanSubstrPatterns(query, new String[] {"columns=[`odd`, `uid`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("flatten/drill-2254-result-mix.json") .build() .run(); }
@Test //DRILL-2197 Left Self Join with complex type in projection @Ignore public void testLeftSelfHashJoinWithMap() throws Exception { final String query = " select a.id, b.oooi.oa.oab.oabc oabc, b.ooof.oa.oab oab from cp.\"join/complex_1.json\" a left outer join cp.\"join/complex_1.json\" b on a.id=b.id order by a.id"; testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("join/DRILL-2197-result-1.json") .build() .run(); }
@Test @Ignore("DRILL-1824") public void schemaChangeValidate() throws Exception { testBuilder() // .sqlQuery("select b from dfs.\"${WORKING_PATH}/src/test/resources/vector/complex/writer/schemaChange/\"") // .unOrdered() // .jsonBaselineFile("/vector/complex/writer/expected.json") // .build() .run(); }
@Test //DRILL-2197 Left Join with complex type in projection @Ignore("enable union type") public void testLeftHashJoinWithMap() throws Exception { final String query = " select a.id, b.oooi.oa.oab.oabc oabc, b.ooof.oa.oab oab from cp.\"join/complex_1.json\" a left outer join cp.\"join/complex_2.json\" b on a.id=b.id order by a.id"; testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("join/DRILL-2197-result-2.json") .build() .run(); }
@Test public void test() throws Exception { testNoResult("CREATE TABLE pdfs.test_table AS SELECT * FROM cp.\"employees.json\""); testBuilder() .sqlQuery("SELECT * FROM pdfs.test_table") .ordered() .jsonBaselineFile("employees.json") .build() .run(); testNoResult("DROP TABLE pdfs.test_table"); } }
@Test //DRILL-2254 supplementary public void testMultiFlattenFromNestedRepeatedList() throws Exception { final String query = "select t.uid, flatten(flatten(t.odd)) odd from cp.\"project/complex/a.json\" t"; testPlanSubstrPatterns(query, new String[] {"columns=[`odd`, `uid`]"}, null); testBuilder() .sqlQuery(query) .unOrdered() .jsonBaselineFile("flatten/drill-2254-result-multi.json") .build() .run(); printResult(testRunAndReturn(QueryType.SQL, query)); }