Search in sources :

Example 71 with TestBuilder

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

the class AvroFormatTest method testMultiDimensionalArray.

@Test
public void testMultiDimensionalArray() throws Exception {
    int numRecords = 5;
    int arraySize = 3;
    String fileName = dataGenerator.generateMultiDimensionalArray(numRecords, arraySize);
    TestBuilder testBuilder = testBuilder().sqlQuery("select * from dfs.`%s`", fileName).unOrdered().baselineColumns("col_array_two_dims");
    for (int i = 0; i < numRecords; i++) {
        JsonStringArrayList<Object> nestedArray = new JsonStringArrayList<>();
        for (int a = 0; a < arraySize; a++) {
            nestedArray.add(listOf(String.format("val_%s_%s_0", i, a), String.format("val_%s_%s_1", i, a)));
        }
        testBuilder.baselineValues(nestedArray);
    }
    testBuilder.go();
}
Also used : 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 72 with TestBuilder

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

the class AvroFormatTest method testDuration.

@Test
public void testDuration() throws Exception {
    int numRows = 5;
    String fileName = dataGenerator.generateDuration(numRows);
    TestBuilder testBuilder = testBuilder().sqlQuery("select * from dfs.`%s`", fileName).unOrdered().baselineColumns("col_duration");
    for (int i = 0; i < numRows; i++) {
        testBuilder.baselineValues(Period.months(10 + i).withDays(100 + i).withMillis(1000 + i));
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 73 with TestBuilder

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

the class AvroFormatTest method testMapSchemaGetByNotExistingKey.

@Test
public void testMapSchemaGetByNotExistingKey() throws Exception {
    String sql = "select map_field['notExists'] as map_field from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, mapTableName).unOrdered().baselineColumns("map_field");
    Object[] nullValue = new Object[] { null };
    for (long i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        testBuilder.baselineValues(nullValue);
    }
    testBuilder.go();
}
Also used : 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 74 with TestBuilder

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

the class AvroFormatTest method testMapSchemaGetByKeyUsingDotNotation.

@Test
public void testMapSchemaGetByKeyUsingDotNotation() throws Exception {
    String sql = "select t.map_field.key1 val1, t.map_field.key2 val2 from dfs.`%s` t";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, mapTableName).unOrdered().baselineColumns("val1", "val2");
    for (long i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        testBuilder.baselineValues(i, i + 1);
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 75 with TestBuilder

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

the class AvroFormatTest method testMapArraySchema.

@Test
public void testMapArraySchema() throws Exception {
    String sql = "select map_array from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, mapTableName).unOrdered().baselineColumns("map_array");
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        List<Object> array = listOf();
        for (int j = 0; j < AvroDataGenerator.ARRAY_SIZE; j++) {
            array.add(mapOfObject("key1", (i + 1) * (j + 50), "key2", (i + 1) * (j + 100)));
        }
        testBuilder.baselineValues(array);
    }
    testBuilder.go();
}
Also used : TestBuilder.mapOfObject(org.apache.drill.test.TestBuilder.mapOfObject) 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