Search in sources :

Example 36 with TestBuilder

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

the class AvroFormatTest method testMapSchemaArrayValue.

@Test
public void testMapSchemaArrayValue() throws Exception {
    String sql = "select map_array_value from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, mapTableName).unOrdered().baselineColumns("map_array_value");
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        List<Object> doubleArray = listOf();
        for (double j = 0; j < AvroDataGenerator.ARRAY_SIZE; j++) {
            doubleArray.add((double) (i + 1) * j);
        }
        testBuilder.baselineValues(mapOfObject("key1", doubleArray, "key2", doubleArray));
    }
    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 37 with TestBuilder

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

the class AvroFormatTest method testArrayMapSchemaGetElementByIndex.

@Test
public void testArrayMapSchemaGetElementByIndex() throws Exception {
    int elementIndex = 1;
    String sql = "select map_array[%d] element from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, elementIndex, mapTableName).unOrdered().baselineColumns("element");
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        testBuilder.baselineValues(mapOfObject("key1", (i + 1) * (elementIndex + 50), "key2", (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 38 with TestBuilder

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

the class AvroFormatTest method testMapSchemaArrayValueGetByKey.

@Test
public void testMapSchemaArrayValueGetByKey() throws Exception {
    String sql = "select map_array_value['key1'] element from dfs.`%s`";
    TestBuilder testBuilder = testBuilder().sqlQuery(sql, dataGenerator.generateMapSchema().getFileName()).unOrdered().baselineColumns("element");
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        List<Object> doubleArray = listOf();
        for (double j = 0; j < AvroDataGenerator.ARRAY_SIZE; j++) {
            doubleArray.add((double) (i + 1) * j);
        }
        testBuilder.baselineValues(doubleArray);
    }
    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 39 with TestBuilder

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

the class AvroFormatTest method testFlattenEmptyComplexArrayMustYieldNoResults.

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

Example 40 with TestBuilder

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

the class AvroFormatTest method testFlattenComplexArray.

// DRILL-4574
@Test
public void testFlattenComplexArray() throws Exception {
    String file = dataGenerator.generateNestedArraySchema().getFileName();
    TestBuilder testBuilder = nestedArrayQueryTestBuilder(file);
    for (int i = 0; i < AvroDataGenerator.RECORD_COUNT; i++) {
        for (int j = 0; j < AvroDataGenerator.ARRAY_SIZE; j++) {
            testBuilder.baselineValues(i, j);
        }
    }
    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