use of org.apache.drill.test.rowSet.RowSet 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.RowSet 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.RowSet in project drill by axbaretto.
the class QueryBuilder method singletonLong.
/**
* Run the query that is expected to return (at least) one row
* with the only (or first) column returning a long value.
* The long value cannot be null.
*
* @return the value of the first column of the first row
* @throws RpcException if anything goes wrong
*/
public long singletonLong() throws RpcException {
RowSet rowSet = rowSet();
if (rowSet == null) {
throw new IllegalStateException("No rows returned");
}
RowSetReader reader = rowSet.reader();
reader.next();
long value = reader.scalar(0).getLong();
rowSet.clear();
return value;
}
use of org.apache.drill.test.rowSet.RowSet in project drill by axbaretto.
the class QueryBuilder method singletonInt.
/**
* Run the query that is expected to return (at least) one row
* with the only (or first) column returning a int value.
* The int value cannot be null.
*
* @return the value of the first column of the first row
* @throws RpcException if anything goes wrong
*/
public int singletonInt() throws RpcException {
RowSet rowSet = rowSet();
if (rowSet == null) {
throw new IllegalStateException("No rows returned");
}
RowSetReader reader = rowSet.reader();
reader.next();
int value = reader.scalar(0).getInt();
rowSet.clear();
return value;
}
use of org.apache.drill.test.rowSet.RowSet in project drill by axbaretto.
the class QueryBuilder method singletonString.
/**
* Run the query that is expected to return (at least) one row
* with the only (or first) column returning a string value.
* The value may be null, in which case a null string is returned.
*
* @return the value of the first column of the first row
* @throws RpcException if anything goes wrong
*/
public String singletonString() throws RpcException {
RowSet rowSet = rowSet();
if (rowSet == null) {
throw new IllegalStateException("No rows returned");
}
RowSetReader reader = rowSet.reader();
reader.next();
String value;
if (reader.scalar(0).isNull()) {
value = null;
} else {
value = reader.scalar(0).getString();
}
rowSet.clear();
return value;
}
Aggregations