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