Search in sources :

Example 61 with TestBuilder

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

the class TestCsvHeader method testEmptyFinalColumn.

@Test
public void testEmptyFinalColumn() throws Exception {
    File table_dir = dirTestWatcher.makeTestTmpSubDir(Paths.get("emptyFinalColumn"));
    BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "a.csvh")));
    os.write("field1,field2\n".getBytes());
    for (int i = 0; i < 10000; i++) {
        os.write("a,\n".getBytes());
    }
    os.flush();
    os.close();
    String query = "select * from dfs.tmp.emptyFinalColumn";
    TestBuilder builder = testBuilder().sqlQuery(query).ordered().baselineColumns("field1", "field2");
    for (int i = 0; i < 10000; i++) {
        builder.baselineValues("a", "");
    }
    builder.go();
}
Also used : FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) TestBuilder(org.apache.drill.test.TestBuilder) Test(org.junit.Test)

Example 62 with TestBuilder

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

the class AvroFormatTest method testMapSchemaComplex_withNullValues.

@Test
public void testMapSchemaComplex_withNullValues() throws Exception {
    final String file = generateMapSchemaComplex_withNullValues().getFileName();
    final 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");
    final List<Object> expectedList = Lists.newArrayList();
    for (int i = 0; i < AvroTestUtil.ARRAY_SIZE; i++) {
        expectedList.add((double) i);
    }
    final List<Object> emptyList = listOf();
    for (int i = 0; i < AvroTestUtil.RECORD_COUNT; i += 2) {
        testBuilder.baselineValues(expectedList, expectedList);
        testBuilder.baselineValues(emptyList, emptyList);
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) Test(org.junit.Test)

Example 63 with TestBuilder

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

the class AvroFormatTest method testFiltersOnVarBinary.

@Test
public void testFiltersOnVarBinary() throws Exception {
    final String file = generateSimplePrimitiveSchema_NoNullValues(5000).getFileName();
    final String sql = "select f_bytes from dfs.`%s` where f_bytes = BINARY_STRING('\\x61\\x31')";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, file).unOrdered().baselineColumns("f_bytes");
    for (int i = 0; i < 500; i++) {
        testBuilder.baselineValues(new byte[] { 'a', '1' });
    }
    testBuilder.go();
    final String sql2 = "select f_bytes from dfs.`%s` where f_bytes IN (BINARY_STRING('\\x61\\x31'))";
    testBuilder = testBuilder().sqlQuery(sql2, file).unOrdered().baselineColumns("f_bytes");
    for (int i = 0; i < 500; i++) {
        testBuilder.baselineValues(new byte[] { 'a', '1' });
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) Test(org.junit.Test)

Example 64 with TestBuilder

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

the class AvroFormatTest method testFlattenEmptyComplexArrayMustYieldNoResults.

// DRILL-4574
@Test
public void testFlattenEmptyComplexArrayMustYieldNoResults() throws Exception {
    final String file = generateNestedArraySchema(AvroTestUtil.RECORD_COUNT, 0).getFilePath();
    TestBuilder testBuilder = nestedArrayQueryTestBuilder(file);
    testBuilder.expectsEmptyResultSet();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) Test(org.junit.Test)

Example 65 with TestBuilder

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

the class AvroFormatTest method testFlattenComplexArray.

// DRILL-4574
@Test
public void testFlattenComplexArray() throws Exception {
    final String file = generateNestedArraySchema().getFileName();
    TestBuilder testBuilder = nestedArrayQueryTestBuilder(file);
    for (int i = 0; i < AvroTestUtil.RECORD_COUNT; i++) {
        for (int j = 0; j < AvroTestUtil.ARRAY_SIZE; j++) {
            testBuilder.baselineValues(i, j);
        }
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) 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