Search in sources :

Example 91 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class TestInfoSchema method showTablesFromDb.

@Test
public void showTablesFromDb() throws Exception {
    List<String[]> expected = Arrays.asList(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" }, new String[] { "information_schema", "FILES" }, new String[] { "information_schema", "PARTITIONS" });
    TestBuilder t1 = testBuilder().sqlQuery("SHOW TABLES FROM INFORMATION_SCHEMA").unOrdered().baselineColumns("TABLE_SCHEMA", "TABLE_NAME");
    for (String[] expectedRow : expected) {
        t1.baselineValues(expectedRow);
    }
    t1.go();
    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 92 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class TestBaseViewSupport method queryViewHelper.

/**
 * Execute the given query and check against the given baseline.
 *
 * @param query
 * @param baselineColumns
 * @param baselineValues
 * @throws Exception
 */
protected static void queryViewHelper(final String query, final String[] baselineColumns, final List<Object[]> baselineValues) throws Exception {
    TestBuilder testBuilder = testBuilder().sqlQuery(query).unOrdered().baselineColumns(baselineColumns);
    for (Object[] values : baselineValues) {
        testBuilder = testBuilder.baselineValues(values);
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder)

Example 93 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

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

Example 94 with TestBuilder

use of org.apache.drill.test.TestBuilder in project drill by apache.

the class BaseTestHiveImpersonation method fromInfoSchemaHelper.

protected void fromInfoSchemaHelper(final String db, List<String> expectedTables, List<TableType> expectedTableTypes) throws Exception {
    final String dbQualified = hivePluginName + "." + 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();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder)

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