use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class BaseTestHiveImpersonation method showTablesHelper.
protected void showTablesHelper(final String db, List<String> expectedTables) throws Exception {
final String dbQualified = hivePluginName + "." + db;
final TestBuilder testBuilder = testBuilder().sqlQuery("SHOW TABLES IN " + dbQualified).unOrdered().baselineColumns("TABLE_SCHEMA", "TABLE_NAME");
if (expectedTables.size() == 0) {
testBuilder.expectsEmptyResultSet();
} else {
for (String tbl : expectedTables) {
testBuilder.baselineValues(dbQualified, tbl);
}
}
testBuilder.go();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class BaseTestHiveImpersonation method fromInfoSchemaHelper.
protected void fromInfoSchemaHelper(final String pluginName, final String db, List<String> expectedTables, List<TableType> expectedTableTypes) throws Exception {
final String dbQualified = pluginName + "." + db;
final TestBuilder testBuilder = testBuilder().sqlQuery("SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE \n" + "FROM INFORMATION_SCHEMA.`TABLES` \n" + "WHERE TABLE_SCHEMA = '" + dbQualified + "'").unOrdered().baselineColumns("TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE");
if (expectedTables.size() == 0) {
testBuilder.expectsEmptyResultSet();
} else {
for (int i = 0; i < expectedTables.size(); ++i) {
testBuilder.baselineValues(dbQualified, expectedTables.get(i), expectedTableTypes.get(i).toString());
}
}
testBuilder.go();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class TestSelectWithOption method testWithResult.
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();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class TestTopNSchemaChanges method testNumericTypes.
@Test
public void testNumericTypes() throws Exception {
// left side int and strings
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(tableDir, "d1.json")));
for (int i = 0; i < 10000; i += 2) {
writer.write(String.format("{ \"kl\" : %d , \"vl\": %d }\n", i, i));
}
writer.close();
writer = new BufferedWriter(new FileWriter(new File(tableDir, "d2.json")));
for (int i = 1; i < 10000; i += 2) {
writer.write(String.format("{ \"kl\" : %f , \"vl\": %f }\n", (float) i, (float) i));
}
writer.close();
TestBuilder builder = testBuilder().sqlQuery("select * from dfs.`%s` order by kl limit 12", TABLE).optionSettingQueriesForTestQuery("alter session set `exec.enable_union_type` = true").ordered().baselineColumns("kl", "vl");
for (long i = 0; i < 12; ++i) {
if (i % 2 == 0) {
builder.baselineValues(i, i);
} else {
builder.baselineValues((double) i, (double) i);
}
}
builder.go();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class TestTopNSchemaChanges method testMissingColumn.
@Test
public void testMissingColumn() throws Exception {
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(tableDir, "d1.json")));
for (int i = 0; i < 100; i++) {
writer.write(String.format("{ \"kl1\" : %d , \"vl1\": %d }\n", i, i));
}
writer.close();
writer = new BufferedWriter(new FileWriter(new File(tableDir, "d2.json")));
for (int i = 100; i < 200; i++) {
writer.write(String.format("{ \"kl\" : %f , \"vl\": %f }\n", (float) i, (float) i));
}
writer.close();
writer = new BufferedWriter(new FileWriter(new File(tableDir, "d3.json")));
for (int i = 200; i < 300; i++) {
writer.write(String.format("{ \"kl2\" : \"%s\" , \"vl2\": \"%s\" }\n", i, i));
}
writer.close();
TestBuilder builder = testBuilder().sqlQuery("select kl, vl, kl1, vl1, kl2, vl2 from dfs.`%s` order by kl limit 3", TABLE).optionSettingQueriesForTestQuery("alter session set `exec.enable_union_type` = true").ordered().baselineColumns("kl", "vl", "kl1", "vl1", "kl2", "vl2").baselineValues(100.0d, 100.0d, null, null, null, null).baselineValues(101.0d, 101.0d, null, null, null, null).baselineValues(102.0d, 102.0d, null, null, null, null);
builder.go();
builder = testBuilder().sqlQuery("select kl, vl, kl1, vl1, kl2, vl2 from dfs.`%s` order by kl1 limit 3", TABLE).optionSettingQueriesForTestQuery("alter session set `exec.enable_union_type` = true").ordered().baselineColumns("kl", "vl", "kl1", "vl1", "kl2", "vl2").baselineValues(null, null, 0l, 0l, null, null).baselineValues(null, null, 1l, 1l, null, null).baselineValues(null, null, 2l, 2l, null, null);
builder.go();
builder = testBuilder().sqlQuery("select kl, vl, kl1, vl1, kl2, vl2 from dfs.`%s` order by kl2 limit 3", TABLE).optionSettingQueriesForTestQuery("alter session set `exec.enable_union_type` = true").ordered().baselineColumns("kl", "vl", "kl1", "vl1", "kl2", "vl2").baselineValues(null, null, null, null, "200", "200").baselineValues(null, null, null, null, "201", "201").baselineValues(null, null, null, null, "202", "202");
builder.go();
// Since client can't handle new columns which are not in first batch, we won't test output of query.
// Query should run w/o any errors.
test("select * from dfs.`%s` order by kl limit 3", TABLE);
}
Aggregations