use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class AvroFormatTest method nestedArrayQueryTestBuilder.
private TestBuilder nestedArrayQueryTestBuilder(String file) {
final String sql = "select rec_nr, array_item['nested_1_int'] as array_item_nested_int from " + "(select a_int as rec_nr, flatten(t.b_array) as array_item from dfs.`%s` t) a";
TestBuilder testBuilder = testBuilder().sqlQuery(sql, file).unOrdered().baselineColumns("rec_nr", "array_item_nested_int");
return testBuilder;
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class TestInfoSchema method showDatabases.
@Test
public void showDatabases() throws Exception {
final List<String[]> expected = ImmutableList.of(new String[] { "dfs.default" }, new String[] { "dfs.root" }, new String[] { "dfs.tmp" }, new String[] { "cp.default" }, new String[] { "sys" }, new String[] { "INFORMATION_SCHEMA" });
final TestBuilder t1 = testBuilder().sqlQuery("SHOW DATABASES").unOrdered().baselineColumns("SCHEMA_NAME");
for (String[] expectedRow : expected) {
t1.baselineValues(expectedRow);
}
t1.go();
final TestBuilder t2 = testBuilder().sqlQuery("SHOW SCHEMAS").unOrdered().baselineColumns("SCHEMA_NAME");
for (String[] expectedRow : expected) {
t2.baselineValues(expectedRow);
}
t2.go();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class TestInfoSchema method showTablesFromDb.
@Test
public void showTablesFromDb() throws Exception {
final List<String[]> expected = ImmutableList.of(new String[] { "INFORMATION_SCHEMA", "VIEWS" }, new String[] { "INFORMATION_SCHEMA", "COLUMNS" }, new String[] { "INFORMATION_SCHEMA", "TABLES" }, new String[] { "INFORMATION_SCHEMA", "CATALOGS" }, new String[] { "INFORMATION_SCHEMA", "SCHEMATA" });
final TestBuilder t1 = testBuilder().sqlQuery("SHOW TABLES FROM INFORMATION_SCHEMA").unOrdered().baselineColumns("TABLE_SCHEMA", "TABLE_NAME");
for (String[] expectedRow : expected) {
t1.baselineValues(expectedRow);
}
t1.go();
final TestBuilder t2 = testBuilder().sqlQuery("SHOW TABLES IN INFORMATION_SCHEMA").unOrdered().baselineColumns("TABLE_SCHEMA", "TABLE_NAME");
for (String[] expectedRow : expected) {
t2.baselineValues(expectedRow);
}
t2.go();
}
use of org.apache.drill.test.TestBuilder in project drill by apache.
the class AvroFormatTest method testArrayMapSchemaElementGetByKey.
@Test
public void testArrayMapSchemaElementGetByKey() throws Exception {
int elementIndex = 1;
String sql = "select map_array[%d]['key2'] val from dfs.`%s`";
TestBuilder testBuilder = testBuilder().sqlQuery(sql, elementIndex, mapTableName).unOrdered().baselineColumns("val");
for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
testBuilder.baselineValues((i + 1) * (elementIndex + 100));
}
testBuilder.go();
}
use of org.apache.drill.test.TestBuilder in project drill by apache.
the class AvroFormatTest method testLinkedList.
@Test
public void testLinkedList() throws Exception {
int numRows = 5;
String file = dataGenerator.generateLinkedList(numRows);
TestBuilder testBuilder = testBuilder().sqlQuery("select * from dfs.`%s` t", file).unOrdered().baselineColumns("value", "next");
for (long i = 0; i < numRows; i++) {
if (i == numRows - 1) {
// last row
testBuilder.baselineValues(i, mapOf("next", new JsonStringHashMap<>()));
continue;
}
testBuilder.baselineValues(i, mapOf("value", i + 1, "next", new JsonStringHashMap<>()));
}
testBuilder.go();
}
Aggregations