private void testWithResult(String query, Object... expectedResult) throws Exception { TestBuilder builder = testBuilder() .sqlQuery(query) .ordered() .baselineColumns("columns"); for (Object o : expectedResult) { builder = builder.baselineValues(o); } builder.build().run(); }
public BaselineQueryTestBuilder physicalPlanBaselineQueryFromFile(String baselinePhysicalPlanPath) throws IOException { String baselineQuery = BaseTestQuery.getFile(baselinePhysicalPlanPath); return new BaselineQueryTestBuilder(baselineQuery, UserBitShared.QueryType.PHYSICAL, allocator, query, queryType, ordered, approximateEquality, baselineTypeMap, baselineOptionSettingQueries, testOptionSettingQueries, highPerformanceComparison, expectedNumBatches); }
public void nullMixedComparatorEqualJoinHelper(final String query) throws Exception { testBuilder() .sqlQuery(query) .unOrdered() .baselineColumns("key", "data", "data0", "key0") .baselineValues("A", "L_A_1", "L_A_1", "A") .baselineValues("A", null, null, "A") .baselineValues("B", null, null, "B") .baselineValues("B", "L_B_1", "L_B_1", "B") .go(); } }
@Test public void testSelStarOrderByLimit() throws Exception{ testBuilder() .ordered() .sqlQuery(" select * from cp.\"employee.json\" order by last_name limit 2") .sqlBaselineQuery(" select employee_id, full_name,first_name,last_name,position_id,position_title,store_id," + " department_id,birth_date,hire_date,salary,supervisor_id,education_level,marital_status,gender,management_role " + " from cp.\"employee.json\" " + " order by last_name limit 2") .build().run(); }
@Test // Union-All where same column is projected twice in right child public void testUnionAll6() throws Exception { String query = "select n_nationkey, n_regionkey from cp.\"tpch/nation.parquet\" where n_regionkey = 1 union all select r_regionkey, r_regionkey from cp.\"tpch/region.parquet\" where r_regionkey = 2"; testBuilder() .sqlQuery(query) .unOrdered() .csvBaselineFile("testframework/testUnionAllQueries/q6.tsv") .baselineTypes(MinorType.INT, MinorType.INT) .baselineColumns("n_nationkey", "n_regionkey") .build().run(); }
@Test // Simple Union over two scans public void testUnionDistinct1() throws Exception { String query = "(select n_regionkey from cp.\"tpch/nation.parquet\") union (select r_regionkey from cp.\"tpch/region.parquet\")"; testBuilder() .sqlQuery(query) .unOrdered() .csvBaselineFile("testframework/unionDistinct/q1.tsv") .baselineTypes(MinorType.INT) .baselineColumns("n_regionkey") .build() .run(); }
@Test public void testCSVVerification() throws Exception { testBuilder() .sqlQuery("select employee_id, first_name, last_name from cp.\"testframework/small_test_data.json\"") .ordered() .csvBaselineFile("testframework/small_test_data.tsv") .baselineTypes(MinorType.BIGINT, MinorType.VARCHAR, MinorType.VARCHAR) .baselineColumns("employee_id", "first_name", "last_name") .build().run(); }
@Test public void testCSVVerificationOfUnorderedComparison() throws Throwable { testBuilder() .sqlQuery("select columns[0] as employee_id, columns[1] as first_name, columns[2] as last_name from cp.\"testframework/small_test_data_reordered.tsv\"") .unOrdered() .csvBaselineFile("testframework/small_test_data.tsv") .baselineColumns("employee_id", "first_name", "last_name") .build().run(); }
@Test public void testSelStarBothSideJoin() throws Exception { testBuilder() .unOrdered() .sqlQuery("select n.*, r.* from cp.\"tpch/nation.parquet\" n, cp.\"tpch/region.parquet\" r where n.n_regionkey = r.r_regionkey") .sqlBaselineQuery("select n.n_nationkey,n.n_name,n.n_regionkey,n.n_comment,r.r_regionkey,r.r_name,r.r_comment from cp.\"tpch/nation.parquet\" n, cp.\"tpch/region.parquet\" r where n.n_regionkey = r.r_regionkey order by n.n_name") .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-3018 public void testNestLoopJoinScalarSubQ() throws Exception { testBuilder() .sqlQuery("select n_nationkey from cp.\"tpch/nation.parquet\" where n_nationkey >= (select min(c_nationkey) from cp.\"tpch/customer.parquet\")") .unOrdered() .sqlBaselineQuery("select n_nationkey from cp.\"tpch/nation.parquet\"") .build() .run(); }
@Test //DRILL-2163 public void testNestedTypesPastJoinReportsValidResult() throws Exception { final String query = "select t1.uid, t1.events, t1.events[0].evnt_id as event_id, t2.transactions, " + "t2.transactions[0] as trans, t1.odd, t2.even from cp.\"project/complex/a.json\" t1, " + "cp.\"project/complex/b.json\" t2 where t1.uid = t2.uid"; testBuilder() .sqlQuery(query) .ordered() .jsonBaselineFile("project/complex/drill-2163-result.json") .build() .run(); }
public void run() throws Exception { if (testBuilder.getExpectedSchema() != null) { compareSchemaOnly(); } else { if (ordered) { compareOrderedResults(); } else { compareUnorderedResults(); } } }
private void addTypeInfoIfMissing(QueryDataBatch batch, TestBuilder testBuilder) { if (! testBuilder.typeInfoSet()) { Map<SchemaPath, MajorType> typeMap = getTypeMapFromBatch(batch); testBuilder.baselineTypes(typeMap); } }
@Test public void testSelStarWhereOrderBy() throws Exception{ testBuilder() .ordered() .sqlQuery("select * from cp.\"employee.json\" where first_name = 'James' order by last_name") .sqlBaselineQuery("select employee_id, full_name,first_name,last_name,position_id,position_title,store_id," + " department_id,birth_date,hire_date,salary,supervisor_id,education_level,marital_status,gender,management_role " + " from cp.\"employee.json\" " + " where first_name = 'James' order by last_name") .build().run(); }
@Test // Union-All where same column is projected twice in left and right child public void testUnionAll6_1() throws Exception { String query = "select n_nationkey, n_nationkey from cp.\"tpch/nation.parquet\" union all select r_regionkey, r_regionkey from cp.\"tpch/region.parquet\""; testBuilder() .sqlQuery(query) .unOrdered() .csvBaselineFile("testframework/testUnionAllQueries/q6_1.tsv") .baselineTypes(MinorType.INT, MinorType.INT) .baselineColumns("n_nationkey", "n_nationkey1") .build().run(); }
@Test public void testSelStarPlusRegCol() throws Exception{ testBuilder() .unOrdered() .sqlQuery("select *, n_nationkey as key2 from cp.\"tpch/nation.parquet\" order by n_name limit 2") .sqlBaselineQuery("select n_comment, n_name, n_nationkey, n_regionkey, n_nationkey as key2 from cp.\"tpch/nation.parquet\" order by n_name limit 2") .build().run(); }
public BaselineQueryTestBuilder sqlBaselineQueryFromFile(String baselineQueryFilename) throws IOException { String baselineQuery = BaseTestQuery.getFile(baselineQueryFilename); return new BaselineQueryTestBuilder(baselineQuery, UserBitShared.QueryType.SQL, allocator, query, queryType, ordered, approximateEquality, baselineTypeMap, baselineOptionSettingQueries, testOptionSettingQueries, highPerformanceComparison, expectedNumBatches); }
@Test public void testSelStarJoin() throws Exception { testBuilder() .ordered() .sqlQuery("select * from cp.\"tpch/nation.parquet\" n, cp.\"tpch/region.parquet\" r where n.n_regionkey = r.r_regionkey order by n.n_name") .sqlBaselineQuery("select n.n_nationkey, n.n_name,n.n_regionkey,n.n_comment,r.r_regionkey,r.r_name, r.r_comment from cp.\"tpch/nation.parquet\" n, cp.\"tpch/region.parquet\" r where n.n_regionkey = r.r_regionkey order by n.n_name") .build().run(); }
@Test public void testSelRightStarJoin() throws Exception { testBuilder() .ordered() .sqlQuery("select r.* from cp.\"tpch/nation.parquet\" n, cp.\"tpch/region.parquet\" r where n.n_regionkey = r.r_regionkey order by n.n_name") .sqlBaselineQuery("select r.r_regionkey, r.r_name, r.r_comment from cp.\"tpch/nation.parquet\" n, cp.\"tpch/region.parquet\" r where n.n_regionkey = r.r_regionkey order by n.n_name") .build().run(); }