use of org.apache.drill.test.rowSet.RowSet.RowSetReader in project drill by apache.
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.column(0).getLong();
rowSet.clear();
return value;
}
use of org.apache.drill.test.rowSet.RowSet.RowSetReader in project drill by apache.
the class RowSetTest method testTinyIntRW.
private void testTinyIntRW() {
BatchSchema batchSchema = new SchemaBuilder().add("col", MinorType.TINYINT).build();
SingleRowSet rs = fixture.rowSetBuilder(batchSchema).add(0).add(Byte.MAX_VALUE).add(Byte.MIN_VALUE).build();
RowSetReader reader = rs.reader();
assertTrue(reader.next());
assertEquals(0, reader.column(0).getInt());
assertTrue(reader.next());
assertEquals(Byte.MAX_VALUE, reader.column(0).getInt());
assertTrue(reader.next());
assertEquals(Byte.MIN_VALUE, reader.column(0).getInt());
assertFalse(reader.next());
rs.clear();
}
use of org.apache.drill.test.rowSet.RowSet.RowSetReader in project drill by apache.
the class RowSetTest method testFloatRW.
private void testFloatRW() {
BatchSchema batchSchema = new SchemaBuilder().add("col", MinorType.FLOAT4).build();
SingleRowSet rs = fixture.rowSetBuilder(batchSchema).add(0F).add(Float.MAX_VALUE).add(Float.MIN_VALUE).build();
RowSetReader reader = rs.reader();
assertTrue(reader.next());
assertEquals(0, reader.column(0).getDouble(), 0.000001);
assertTrue(reader.next());
assertEquals(Float.MAX_VALUE, reader.column(0).getDouble(), 0.000001);
assertTrue(reader.next());
assertEquals(Float.MIN_VALUE, reader.column(0).getDouble(), 0.000001);
assertFalse(reader.next());
rs.clear();
}
Aggregations