Search in sources :

Example 91 with RowSetComparison

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 92 with RowSetComparison

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 93 with RowSetComparison

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 94 with RowSetComparison

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 95 with RowSetComparison

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)289 Test (org.junit.Test)271 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)232 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)211 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)191 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)142 ClusterTest (org.apache.drill.test.ClusterTest)138 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)54 SubOperatorTest (org.apache.drill.test.SubOperatorTest)53 QueryBuilder (org.apache.drill.test.QueryBuilder)48 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)42 OperatorTest (org.apache.drill.categories.OperatorTest)38 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)29 RowSet (org.apache.drill.test.rowSet.RowSet)26 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)26 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)25 StreamingAggregate (org.apache.drill.exec.physical.config.StreamingAggregate)19 StreamingAggBatch (org.apache.drill.exec.physical.impl.aggregate.StreamingAggBatch)19 RowSetLoader (org.apache.drill.exec.physical.rowSet.RowSetLoader)18 BatchSchema (org.apache.drill.exec.record.BatchSchema)18