Search in sources :

Example 66 with TestBuilder

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;
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder)

Example 67 with 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();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) Test(org.junit.Test) SqlTest(org.apache.drill.categories.SqlTest)

Example 68 with TestBuilder

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();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) Test(org.junit.Test) SqlTest(org.apache.drill.categories.SqlTest)

Example 69 with TestBuilder

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();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 70 with TestBuilder

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();
}
Also used : JsonStringHashMap(org.apache.drill.exec.util.JsonStringHashMap) TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

TestBuilder (org.apache.drill.test.TestBuilder)94 Test (org.junit.Test)74 File (java.io.File)27 OperatorTest (org.apache.drill.categories.OperatorTest)27 ClusterTest (org.apache.drill.test.ClusterTest)20 BufferedWriter (java.io.BufferedWriter)18 FileWriter (java.io.FileWriter)18 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)16 ParquetTest (org.apache.drill.categories.ParquetTest)10 TestBuilder.mapOfObject (org.apache.drill.test.TestBuilder.mapOfObject)6 Path (java.nio.file.Path)5 JsonFileBuilder (org.apache.drill.test.rowSet.file.JsonFileBuilder)5 Category (org.junit.experimental.categories.Category)5 SlowTest (org.apache.drill.categories.SlowTest)4 SqlTest (org.apache.drill.categories.SqlTest)4 JsonStringHashMap (org.apache.drill.exec.util.JsonStringHashMap)4 IOException (java.io.IOException)3 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)3 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)3 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)3