Search in sources :

Example 41 with TestBuilder

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

the class AvroFormatTest method testMapSchemaArrayValueGetByKeyElementByIndex.

@Test
public void testMapSchemaArrayValueGetByKeyElementByIndex() throws Exception {
    String sql = "select map_array_value['key1'][3] element from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, mapTableName).unOrdered().baselineColumns("element");
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        double val = (double) (i + 1) * 3;
        testBuilder.baselineValues(val);
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 42 with TestBuilder

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

the class AvroFormatTest method testMapSchemaValueInFilter2.

@Test
public void testMapSchemaValueInFilter2() throws Exception {
    String sql = "select map_array[%d]['key2'] val from dfs.`%s` where map_array[%d]['key2'] > %d";
    int elementIndex = 1;
    int startRecord = 30;
    int filterValue = startRecord * (elementIndex + 100);
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, elementIndex, mapTableName, elementIndex, filterValue).unOrdered().baselineColumns("val");
    for (int i = startRecord; 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 43 with TestBuilder

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

the class AvroFormatTest method testFlattenPrimitiveArray.

// DRILL-4574
@Test
public void testFlattenPrimitiveArray() throws Exception {
    String file = dataGenerator.generateSimpleArraySchema_NoNullValues().getFileName();
    String sql = "select a_string, flatten(c_string_array) as array_item from dfs.`%s` t";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, file).unOrdered().baselineColumns("a_string", "array_item");
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        for (int j = 0; j < AvroDataGenerator.ARRAY_SIZE; j++) {
            testBuilder.baselineValues("a_" + i, "c_string_array_" + i + "_" + j);
        }
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 44 with TestBuilder

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

the class AvroFormatTest method testMapSchemaValueInFilter.

@Test
public void testMapSchemaValueInFilter() throws Exception {
    String sql = "select map_field['key1'] val from dfs.`%s` where map_field['key1'] < %d";
    long filterValue = AvroDataGenerator.RECORD_COUNT / 10;
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, mapTableName, filterValue).unOrdered().baselineColumns("val");
    for (long i = 0; i < filterValue; i++) {
        testBuilder.baselineValues(i);
    }
    testBuilder.go();
}
Also used : TestBuilder(org.apache.drill.test.TestBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 45 with TestBuilder

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

the class AvroFormatTest method testMapSchemaGetByKey.

@Test
public void testMapSchemaGetByKey() throws Exception {
    String sql = "select map_field['key1'] val1, map_field['key2'] val2 from dfs.`%s`";
    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)

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