public TestBuilder sqlQueryFromFile(String queryFile) throws IOException { String query = BaseTestQuery.getFile(queryFile); this.query = query; this.queryType = UserBitShared.QueryType.SQL; return this; }
public TestBuilder physicalPlanFromFile(String queryFile) throws IOException { String query = BaseTestQuery.getFile(queryFile); this.query = query; this.queryType = UserBitShared.QueryType.PHYSICAL; return this; }
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); }
/** * Copy the resource (ex. file on classpath) to a physical file on FileSystem. * @param resource * @return the file path * @throws IOException */ public static String getPhysicalFileFromResource(final String resource) throws IOException { final File file = File.createTempFile("tempfile", ".txt"); file.deleteOnExit(); final PrintWriter printWriter = new PrintWriter(file); printWriter.write(BaseTestQuery.getFile(resource)); printWriter.close(); return file.getPath(); }
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); }
protected static List<QueryDataBatch> testPhysicalFromFileWithResults(String file) throws Exception { return testRunAndReturn(QueryType.PHYSICAL, getFile(file)); }
protected static void testLogicalFromFile(String file) throws Exception{ testLogical(getFile(file)); }
protected static void testSqlFromFile(String file) throws Exception{ test(getFile(file)); }
protected static int testPhysicalFromFile(String file) throws Exception{ return testPhysical(getFile(file)); }
@Test // repeated list within a repeated map public void drill1673() throws Exception { String path = folder.getRoot().toPath().toString(); String jsonRecords = BaseTestQuery.getFile("store/json/1673.json"); int numCopies = 25000; new TestConstantFolding.SmallFileCreator(folder) .setRecord(jsonRecords) .createFiles(1, numCopies, "json"); String query = "select t.fixed_column as fixed_column, flatten(t.list_column) as list_col from dfs.\"" + path + "/bigfile/bigfile.json\" as t"; String plan = getPlanInString("explain plan for " + query, OPTIQ_FORMAT); // There are only two columns fixed_column and list_column, so * is also possible assertTrue(plan, plan.contains("columns=[`list_column`, `fixed_column`]") || plan.contains("columns=[`*`]")); TestBuilder builder = testBuilder() .sqlQuery(query) .baselineColumns("fixed_column", "list_col") .unOrdered(); Object map1 = mapOf("id1", "1", "name", "zhu", "num", listOf(listOf(1l, 2l, 3l))); Object map2 = mapOf("id1", "2", "name", "hao", "num", listOf(listOf(4l, 5l, 6l))); for (int i = 0; i < numCopies; i++) { builder.baselineValues("abc", map1); builder.baselineValues("abc", map2); } builder.go(); }
String path = folder.getRoot().toPath().toString(); String jsonRecords = BaseTestQuery.getFile("flatten/complex_transaction_example_data.json"); int numCopies = 700; new TestConstantFolding.SmallFileCreator(folder)