use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.
the class TestSorter method testEmptyRowSet.
// Test degenerate case: no rows
@Test
public void testEmptyRowSet() throws Exception {
BatchSchema schema = SortTestUtilities.nonNullSchema();
SingleRowSet rowSet = new RowSetBuilder(fixture.allocator(), schema).withSv2().build();
SingleRowSet expected = new RowSetBuilder(fixture.allocator(), schema).build();
runSorterTest(rowSet, expected);
}
use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.
the class TestExternalSort method testNewColumns.
private void testNewColumns(boolean testLegacy) throws Exception {
final int record_count = 10000;
final String tableDirName = "newColumns";
{
final BatchSchema schema = new SchemaBuilder().add("a", TypeProtos.MinorType.INT).add("b", TypeProtos.MinorType.INT).build();
final RowSetBuilder rowSetBuilder = new RowSetBuilder(allocator, schema);
for (int i = 0; i <= record_count; i += 2) {
rowSetBuilder.addRow(i, i);
}
final RowSet rowSet = rowSetBuilder.build();
final File tableFile = createTableFile(tableDirName, "a.json");
new JsonFileBuilder(rowSet).build(tableFile);
rowSet.clear();
}
{
final BatchSchema schema = new SchemaBuilder().add("a", TypeProtos.MinorType.INT).add("c", TypeProtos.MinorType.INT).build();
final RowSetBuilder rowSetBuilder = new RowSetBuilder(allocator, schema);
for (int i = 1; i <= record_count; i += 2) {
rowSetBuilder.addRow(i, i);
}
final RowSet rowSet = rowSetBuilder.build();
final File tableFile = createTableFile(tableDirName, "b.json");
new JsonFileBuilder(rowSet).build(tableFile);
rowSet.clear();
}
// Test framework currently doesn't handle changing schema (i.e. new
// columns) on the client side
TestBuilder builder = testBuilder().sqlQuery("select a, b, c from dfs.`%s` order by a desc", tableDirName).ordered().optionSettingQueriesForTestQuery(getOptions(testLegacy)).baselineColumns("a", "b", "c");
for (int i = record_count; i >= 0; ) {
builder.baselineValues((long) i, (long) i--, null);
if (i >= 0) {
builder.baselineValues((long) i, null, (long) i--);
}
}
builder.go();
// TODO: Useless test: just dumps to console
test("select * from dfs.`%s` order by a desc", tableDirName);
}
use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.
the class TestExternalSort method testNumericAndStringTypes.
private void testNumericAndStringTypes(boolean testLegacy) throws Exception {
final int record_count = 10000;
final String tableDirName = "numericAndStringTypes";
{
final BatchSchema schema = new SchemaBuilder().add("a", Types.required(TypeProtos.MinorType.INT)).build();
final RowSetBuilder rowSetBuilder = new RowSetBuilder(allocator, schema);
for (int i = 0; i <= record_count; i += 2) {
rowSetBuilder.addRow(i);
}
final RowSet rowSet = rowSetBuilder.build();
final File tableFile = createTableFile(tableDirName, "a.json");
new JsonFileBuilder(rowSet).build(tableFile);
rowSet.clear();
}
{
final BatchSchema schema = new SchemaBuilder().add("a", Types.required(TypeProtos.MinorType.INT)).build();
final RowSetBuilder rowSetBuilder = new RowSetBuilder(allocator, schema);
for (int i = 1; i <= record_count; i += 2) {
rowSetBuilder.addRow(i);
}
final RowSet rowSet = rowSetBuilder.build();
final File tableFile = createTableFile(tableDirName, "b.json");
new JsonFileBuilder(rowSet).setCustomFormatter("a", "\"%05d\"").build(tableFile);
rowSet.clear();
}
TestBuilder builder = testBuilder().sqlQuery("select * from dfs.`%s` order by a desc", tableDirName).ordered().optionSettingQueriesForTestQuery(getOptions(testLegacy)).baselineColumns("a");
// Strings come first because order by is desc
for (int i = record_count; i >= 0; ) {
i--;
if (i >= 0) {
builder.baselineValues(String.format("%05d", i--));
}
}
for (int i = record_count; i >= 0; ) {
builder.baselineValues((long) i--);
i--;
}
builder.go();
}
use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.
the class AbstractGenericCopierTest method testAppendRecords.
@Test
public void testAppendRecords() throws SchemaChangeException {
try (RootAllocator allocator = new RootAllocator(10_000_000)) {
final BatchSchema batchSchema = createTestSchema(BatchSchema.SelectionVectorMode.NONE);
final RowSet srcRowSet = createSrcRowSet(allocator);
final RowSet destRowSet = new RowSetBuilder(allocator, batchSchema).build();
final VectorContainer destContainer = destRowSet.container();
final Copier copier = createCopier();
final RowSet expectedRowSet = createExpectedRowset(allocator);
copier.setup(new RowSetBatch(srcRowSet), destContainer);
copier.appendRecord(0);
copier.appendRecords(1, 2);
try {
new RowSetComparison(expectedRowSet).verify(destRowSet);
} finally {
srcRowSet.clear();
if (srcRowSet instanceof RowSet.HyperRowSet) {
((RowSet.HyperRowSet) srcRowSet).getSv4().clear();
}
destRowSet.clear();
expectedRowSet.clear();
}
}
}
use of org.apache.drill.test.rowSet.RowSetBuilder in project drill by axbaretto.
the class GenericSV4CopierTest method createSrcRowSet.
@Override
public RowSet createSrcRowSet(RootAllocator allocator) throws SchemaChangeException {
final BatchSchema batchSchema = createTestSchema(BatchSchema.SelectionVectorMode.NONE);
final DrillBuf drillBuf = allocator.buffer(4 * 3);
final SelectionVector4 sv4 = new SelectionVector4(drillBuf, 3, Character.MAX_VALUE);
final VectorContainer batch1 = new RowSetBuilder(allocator, batchSchema).addRow(row1()).addRow(row4()).build().container();
final VectorContainer batch2 = new RowSetBuilder(allocator, batchSchema).addRow(row2()).addRow(row5()).addRow(row3()).build().container();
final ExpandableHyperContainer hyperContainer = new ExpandableHyperContainer(batch1);
hyperContainer.addBatch(batch2);
sv4.set(0, 0, 0);
sv4.set(1, 1, 0);
sv4.set(2, 1, 2);
return new HyperRowSetImpl(hyperContainer, sv4);
}
Aggregations