use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestHDF5Format method testInt32ScalarQuery.
@Test
public void testInt32ScalarQuery() throws Exception {
String sql = "SELECT flatten(int32) AS int_col\n" + "FROM dfs.`hdf5/scalar.h5`\n" + "WHERE path='/datatype/int32'";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("int_col", TypeProtos.MinorType.INT, TypeProtos.DataMode.REQUIRED).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(-2147483648).addRow(1).addRow(2).addRow(3).addRow(4).addRow(5).addRow(6).addRow(7).addRow(8).addRow(2147483647).build();
new RowSetComparison(expected).unorderedVerifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestHDF5Format method test4DScalarQuery.
@Test
public void test4DScalarQuery() throws Exception {
String sql = "SELECT int_data[0] AS col1,\n" + "int_data[1] AS col2\n" + "FROM\n" + "(\n" + "SELECT flatten(int_data) AS int_data\n" + "FROM dfs.`hdf5/scalar.h5`\n" + "WHERE path='/nd/4D'\n" + ") AS t1";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("col1", MinorType.INT, DataMode.OPTIONAL).add("col2", MinorType.INT, DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(-2147483648, 5).addRow(1, 6).build();
new RowSetComparison(expected).unorderedVerifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestHDF5Format method test1DScalarQuery.
@Test
public void test1DScalarQuery() throws Exception {
String sql = "SELECT int_col FROM (SELECT FLATTEN(`1D`) AS int_col\n" + "FROM dfs.`hdf5/scalar.h5`\n" + "WHERE path='/nd/1D') WHERE int_col < 5";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("int_col", TypeProtos.MinorType.INT, TypeProtos.DataMode.REQUIRED).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(-2147483648).addRow(1).addRow(2).addRow(3).addRow(4).build();
new RowSetComparison(expected).unorderedVerifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestHDF5Format method testFlattenInt64ScalarQuery.
@Test
public void testFlattenInt64ScalarQuery() throws Exception {
String sql = "SELECT * FROM table(dfs.`hdf5/scalar.h5` (type => 'hdf5', defaultPath => '/datatype/int64'))";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("int64", TypeProtos.MinorType.BIGINT, TypeProtos.DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(-9223372036854775808L).addRow(1L).addRow(2L).addRow(3L).addRow(4L).addRow(5L).addRow(6L).addRow(7L).addRow(8L).addRow(9223372036854775807L).build();
new RowSetComparison(expected).unorderedVerifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestHDF5Format method testFlattenColumnQuery.
@Test
public void testFlattenColumnQuery() throws RpcException {
String sql = "SELECT data[0] AS col1,\n" + "data[1] as col2,\n" + "data[2] as col3\n" + "FROM \n" + "(\n" + "SELECT FLATTEN(double_data) AS data \n" + "FROM dfs.`hdf5/browsing.h5` WHERE path='/groupB/dmat'\n" + ")";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("col1", MinorType.FLOAT8, DataMode.OPTIONAL).add("col2", MinorType.FLOAT8, DataMode.OPTIONAL).add("col3", MinorType.FLOAT8, DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1.1, 2.2, 3.3).addRow(4.4, 5.5, 6.6).addRow(7.7, 8.8, 9.9).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
Aggregations