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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations