Search in sources :

Example 46 with TestBuilder

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

the class AvroFormatTest method testMapSchemaComplex_withNullValues.

@Test
public void testMapSchemaComplex_withNullValues() throws Exception {
    String file = dataGenerator.generateMapSchemaComplex_withNullValues().getFileName();
    String sql = "select d_map['key1'] nested_key1, d_map['key2'] nested_key2 from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, file).unOrdered().baselineColumns("nested_key1", "nested_key2");
    List<Object> expectedList = new ArrayList<>();
    for (int i = 0; i < AvroDataGenerator.ARRAY_SIZE; i++) {
        expectedList.add((double) i);
    }
    List<Object> emptyList = listOf();
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i += 2) {
        testBuilder.baselineValues(expectedList, expectedList);
        testBuilder.baselineValues(emptyList, emptyList);
    }
    testBuilder.go();
}
Also used : ArrayList(java.util.ArrayList) JsonStringArrayList(org.apache.drill.exec.util.JsonStringArrayList) TestBuilder.mapOfObject(org.apache.drill.test.TestBuilder.mapOfObject) TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 47 with TestBuilder

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

the class TestInfoSchema method showDatabases.

@Test
public void showDatabases() throws Exception {
    List<String> expected = Arrays.asList("dfs.default", "dfs.root", "dfs.tmp", "cp.default", "sys", "information_schema");
    TestBuilder t1 = testBuilder().sqlQuery("SHOW DATABASES").unOrdered().baselineColumns("SCHEMA_NAME");
    expected.forEach(t1::baselineValues);
    t1.go();
    TestBuilder t2 = testBuilder().sqlQuery("SHOW SCHEMAS").unOrdered().baselineColumns("SCHEMA_NAME");
    expected.forEach(t2::baselineValues);
    t2.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) Test(org.junit.Test) SqlTest(org.apache.drill.categories.SqlTest)

Example 48 with TestBuilder

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

the class TestInfoSchemaOnHiveStorage method describeHelper.

private static void describeHelper(final String options, final String describeCmd) throws Exception {
    final TestBuilder builder = testBuilder();
    if (!Strings.isNullOrEmpty(options)) {
        builder.optionSettingQueriesForTestQuery(options);
    }
    builder.sqlQuery(describeCmd).unOrdered().baselineColumns(baselineCols).baselineValues(expVal1).baselineValues(expVal2).go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder)

Example 49 with TestBuilder

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

the class TestInfoSchemaOnHiveStorage method describeHelper.

private static void describeHelper(final String options, final String describeCmd) throws Exception {
    final TestBuilder builder = testBuilder();
    if (!Strings.isNullOrEmpty(options)) {
        builder.optionSettingQueriesForTestQuery(options);
    }
    builder.sqlQuery(describeCmd).unOrdered().baselineColumns(baselineCols).baselineValues(expVal1).baselineValues(expVal2).go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder)

Example 50 with TestBuilder

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

the class TestCorruptParquetDateCorrection method testReadOldMetadataCacheFile.

@Test
public void testReadOldMetadataCacheFile() throws Exception {
    // for sanity, try reading all partitions without a filter
    String query = format("select date_col from dfs.`%s`", PARTITIONED_1_2_FOLDER);
    TestBuilder builder = testBuilder().sqlQuery(query).unOrdered().baselineColumns("date_col");
    addDateBaselineValues(builder);
    builder.go();
    testPlanMatchingPatterns(query, new String[] { "usedMetadataFile=true" }, null);
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ParquetTest(org.apache.drill.categories.ParquetTest) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

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