use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class TestMergeJoinWithSchemaChanges method testNumericTypes.
@Test
public void testNumericTypes() throws Exception {
// First create data for numeric types.
// left side int and float vs right side float
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(leftDir, "l1.json")));
for (int i = 0; i < 5000; ++i) {
writer.write(String.format("{ \"kl\" : %d , \"vl\": %d }\n", i, i));
}
writer.close();
writer = new BufferedWriter(new FileWriter(new File(leftDir, "l2.json")));
for (int i = 1000; i < 6000; ++i) {
writer.write(String.format("{ \"kl\" : %f , \"vl\": %f }\n", (float) i, (float) i));
}
writer.close();
// right side is int and float
writer = new BufferedWriter(new FileWriter(new File(rightDir, "r1.json")));
for (int i = 2000; i < 7000; ++i) {
writer.write(String.format("{ \"kr\" : %d , \"vr\": %d }\n", i, i));
}
writer.close();
writer = new BufferedWriter(new FileWriter(new File(rightDir, "r2.json")));
for (int i = 3000; i < 8000; ++i) {
writer.write(String.format("{ \"kr\" : %f, \"vr\": %f }\n", (float) i, (float) i));
}
writer.close();
// INNER JOIN
String query = String.format("select * from dfs.`%s` L %s join dfs.`%s` R on L.kl=R.kr", LEFT_DIR, "inner", RIGHT_DIR);
TestBuilder builder = testBuilder().sqlQuery(query).optionSettingQueriesForTestQuery("alter session set `planner.enable_hashjoin` = false; alter session set `exec.enable_union_type` = true").unOrdered().baselineColumns("kl", "vl", "kr", "vr");
for (long i = 2000; i < 3000; ++i) {
builder.baselineValues(i, i, i, i);
builder.baselineValues((double) i, (double) i, i, i);
}
for (long i = 3000; i < 5000; ++i) {
builder.baselineValues(i, i, i, i);
builder.baselineValues(i, i, (double) i, (double) i);
builder.baselineValues((double) i, (double) i, i, i);
builder.baselineValues((double) i, (double) i, (double) i, (double) i);
}
for (long i = 5000; i < 6000; ++i) {
builder.baselineValues((double) i, (double) i, i, i);
builder.baselineValues((double) i, (double) i, (double) i, (double) i);
}
builder.go();
// LEFT JOIN
query = String.format("select * from dfs.`%s` L %s join dfs.`%s` R on L.kl=R.kr", LEFT_DIR, "left", RIGHT_DIR);
builder = testBuilder().sqlQuery(query).optionSettingQueriesForTestQuery("alter session set `planner.enable_hashjoin` = false; alter session set `exec.enable_union_type` = true").unOrdered().baselineColumns("kl", "vl", "kr", "vr");
for (long i = 0; i < 2000; ++i) {
builder.baselineValues(i, i, null, null);
}
for (long i = 1000; i < 2000; ++i) {
builder.baselineValues((double) i, (double) i, null, null);
}
for (long i = 2000; i < 3000; ++i) {
builder.baselineValues(i, i, i, i);
builder.baselineValues((double) i, (double) i, i, i);
}
for (long i = 3000; i < 5000; ++i) {
builder.baselineValues(i, i, i, i);
builder.baselineValues(i, i, (double) i, (double) i);
builder.baselineValues((double) i, (double) i, i, i);
builder.baselineValues((double) i, (double) i, (double) i, (double) i);
}
for (long i = 5000; i < 6000; ++i) {
builder.baselineValues((double) i, (double) i, i, i);
builder.baselineValues((double) i, (double) i, (double) i, (double) i);
}
builder.go();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class TestBaseViewSupport method queryViewHelper.
/**
* Execute the given query and check against the given baseline.
*
* @param query
* @param baselineColumns
* @param baselineValues
* @throws Exception
*/
protected static void queryViewHelper(final String query, final String[] baselineColumns, final List<Object[]> baselineValues) throws Exception {
TestBuilder testBuilder = testBuilder().sqlQuery(query).unOrdered().baselineColumns(baselineColumns);
for (Object[] values : baselineValues) {
testBuilder = testBuilder.baselineValues(values);
}
testBuilder.go();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class AvroFormatTest method testDoubleNestedSchema_NoNullValues.
@Test
public void testDoubleNestedSchema_NoNullValues() throws Exception {
final String file = generateDoubleNestedSchema_NoNullValues().getFileName();
final String sql = "select a_string, b_int, t.c_record.nested_1_string, t.c_record.nested_1_int, " + "t.c_record.nested_1_record.double_nested_1_string, " + "t.c_record.nested_1_record.double_nested_1_int " + "from dfs.`%s` t";
test(sql, file);
final String sql2 = "select t.c_record.nested_1_string from dfs.`%s` t limit 1";
TestBuilder testBuilder = testBuilder().sqlQuery(sql2, file).unOrdered().baselineColumns("EXPR$0");
for (int i = 0; i < 1; i++) {
testBuilder.baselineValues("nested_1_string_" + i);
}
testBuilder.go();
}
use of org.apache.drill.test.TestBuilder in project drill by axbaretto.
the class AvroFormatTest method testFlattenPrimitiveArray.
// DRILL-4574"></a>
@Test
public void testFlattenPrimitiveArray() throws Exception {
final String file = generateSimpleArraySchema_NoNullValues().getFileName();
final 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 < AvroTestUtil.RECORD_COUNT; i++) {
for (int j = 0; j < AvroTestUtil.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 axbaretto.
the class TestComplexTypeReader method test_array.
// DRILL-4410
@Test
public // ListVector allocation
void test_array() throws Exception {
long numRecords = 100000;
final String file1 = "arrays1.json";
final String file2 = "arrays2.json";
final Path path1 = dirTestWatcher.getRootDir().toPath().resolve(file1);
final Path path2 = dirTestWatcher.getRootDir().toPath().resolve(file2);
Files.createFile(path1);
Files.createFile(path2);
final String arrayString = "[ \"abcdef\", \"ghijkl\", \"mnopqr\", \"stuvwx\", \"yz1234\", \"567890\" ] ";
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(path1.toFile(), true)))) {
for (long i = 0; i < numRecords; i++) {
out.println("{ \"id\" : " + i + ", \"array\" : " + arrayString + "}");
}
} catch (IOException e) {
throw e;
}
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(path2.toFile(), true)))) {
for (long i = 0; i < numRecords; i++) {
out.println("{ \"id\" : " + i + ", \"array\" : " + arrayString + "}");
}
} catch (IOException e) {
throw e;
}
TestBuilder testBuilder = testBuilder().sqlQuery("select * from dfs.`%s` `arrays1` INNER JOIN dfs.`%s` `arrays2` ON " + "(`arrays1`.id = `arrays2`.id)", file1, file2).unOrdered().baselineColumns("id", "id0", "array", "array0");
for (long i = 0; i < numRecords; i++) {
testBuilder.baselineValues(i, i, listOf("abcdef", "ghijkl", "mnopqr", "stuvwx", "yz1234", "567890"), listOf("abcdef", "ghijkl", "mnopqr", "stuvwx", "yz1234", "567890"));
}
testBuilder.go();
}
Aggregations