Search in sources :

Example 61 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class PhoenixSQLTest method testExplicitQuery.

@Test
public void testExplicitQuery() throws Exception {
    String sql = "select n_nationkey, n_regionkey, n_name from phoenix123.v1.nation";
    QueryBuilder builder = queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    TupleMetadata schema = new SchemaBuilder().addNullable("n_nationkey", MinorType.BIGINT).addNullable("n_regionkey", MinorType.BIGINT).addNullable("n_name", MinorType.VARCHAR).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(0, 0, "ALGERIA").addRow(1, 1, "ARGENTINA").addRow(2, 1, "BRAZIL").addRow(3, 1, "CANADA").addRow(4, 4, "EGYPT").addRow(5, 0, "ETHIOPIA").addRow(6, 3, "FRANCE").addRow(7, 3, "GERMANY").addRow(8, 2, "INDIA").addRow(9, 2, "INDONESIA").addRow(10, 4, "IRAN").addRow(11, 4, "IRAQ").addRow(12, 2, "JAPAN").addRow(13, 4, "JORDAN").addRow(14, 0, "KENYA").addRow(15, 0, "MOROCCO").addRow(16, 0, "MOZAMBIQUE").addRow(17, 1, "PERU").addRow(18, 2, "CHINA").addRow(19, 3, "ROMANIA").addRow(20, 4, "SAUDI ARABIA").addRow(21, 2, "VIETNAM").addRow(22, 3, "RUSSIA").addRow(23, 3, "UNITED KINGDOM").addRow(24, 1, "UNITED STATES").build();
    new RowSetComparison(expected).verifyAndClearAll(sets);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 62 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class SecuredPhoenixSQLTest method testJoinWithFilterPushdown.

@Test
@Disabled("use the remote query server directly without minicluster")
public void testJoinWithFilterPushdown() throws Exception {
    String sql = "select 10 as DRILL, a.n_name, b.r_name from phoenix123.v1.nation a join phoenix123.v1.region b " + "on a.n_regionkey = b.r_regionkey where b.r_name = 'ASIA'";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    builder.planMatcher().exclude("Join").exclude("Filter").include("Phoenix\\(.* INNER JOIN .* WHERE").match();
    TupleMetadata schema = new SchemaBuilder().addNullable("DRILL", MinorType.INT).addNullable("n_name", MinorType.VARCHAR).addNullable("r_name", MinorType.VARCHAR).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(10, "INDIA", "ASIA").addRow(10, "INDONESIA", "ASIA").addRow(10, "JAPAN", "ASIA").addRow(10, "CHINA", "ASIA").addRow(10, "VIETNAM", "ASIA").build();
    new RowSetComparison(expected).verifyAndClearAll(sets);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder) Test(org.junit.jupiter.api.Test) SlowTest(org.apache.drill.categories.SlowTest) Disabled(org.junit.jupiter.api.Disabled)

Example 63 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class SecuredPhoenixSQLTest method doTestExplicitQuery.

private void doTestExplicitQuery() throws Exception {
    String sql = "select n_nationkey, n_regionkey, n_name from phoenix123.v1.nation";
    QueryBuilder builder = queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    TupleMetadata schema = new SchemaBuilder().addNullable("n_nationkey", MinorType.BIGINT).addNullable("n_regionkey", MinorType.BIGINT).addNullable("n_name", MinorType.VARCHAR).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(0, 0, "ALGERIA").addRow(1, 1, "ARGENTINA").addRow(2, 1, "BRAZIL").addRow(3, 1, "CANADA").addRow(4, 4, "EGYPT").addRow(5, 0, "ETHIOPIA").addRow(6, 3, "FRANCE").addRow(7, 3, "GERMANY").addRow(8, 2, "INDIA").addRow(9, 2, "INDONESIA").addRow(10, 4, "IRAN").addRow(11, 4, "IRAQ").addRow(12, 2, "JAPAN").addRow(13, 4, "JORDAN").addRow(14, 0, "KENYA").addRow(15, 0, "MOROCCO").addRow(16, 0, "MOZAMBIQUE").addRow(17, 1, "PERU").addRow(18, 2, "CHINA").addRow(19, 3, "ROMANIA").addRow(20, 4, "SAUDI ARABIA").addRow(21, 2, "VIETNAM").addRow(22, 3, "RUSSIA").addRow(23, 3, "UNITED KINGDOM").addRow(24, 1, "UNITED STATES").build();
    new RowSetComparison(expected).verifyAndClearAll(sets);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder)

Example 64 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class SecuredPhoenixSQLTest method doTestLimitPushdown.

private void doTestLimitPushdown() throws Exception {
    String sql = "select n_name, n_regionkey from phoenix123.v1.nation limit 20 offset 10";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    builder.planMatcher().exclude("Limit").include("OFFSET .* ROWS FETCH NEXT .* ROWS ONLY").match();
    assertEquals(15, sets.rowCount());
    TupleMetadata schema = new SchemaBuilder().addNullable("n_name", MinorType.VARCHAR).addNullable("n_regionkey", MinorType.BIGINT).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("IRAN", 4).addRow("IRAQ", 4).addRow("JAPAN", 2).addRow("JORDAN", 4).addRow("KENYA", 0).addRow("MOROCCO", 0).addRow("MOZAMBIQUE", 0).addRow("PERU", 1).addRow("CHINA", 2).addRow("ROMANIA", 3).addRow("SAUDI ARABIA", 4).addRow("VIETNAM", 2).addRow("RUSSIA", 3).addRow("UNITED KINGDOM", 3).addRow("UNITED STATES", 1).build();
    new RowSetComparison(expected).verifyAndClearAll(sets);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder)

Example 65 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class PhoenixDataTypeTest method testArrayType.

@Test
public void testArrayType() throws Exception {
    String sql = "select * from phoenix123.v1.arraytype";
    QueryBuilder builder = queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    TupleMetadata schema = new SchemaBuilder().addNullable("T_UUID", MinorType.VARCHAR).addArray("T_VARCHAR", MinorType.VARCHAR).addArray("T_CHAR", MinorType.VARCHAR).addArray("T_BIGINT", MinorType.BIGINT).addArray("T_INTEGER", MinorType.INT).addArray("T_DOUBLE", MinorType.FLOAT8).addArray("T_SMALLINT", MinorType.SMALLINT).addArray("T_TINYINT", MinorType.TINYINT).addArray("T_BOOLEAN", MinorType.BIT).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(U_U_I_D, strArray("apache", "drill", "1.20"), strArray("a", "b", "c"), longArray(Long.MIN_VALUE, Long.MAX_VALUE), intArray(Integer.MIN_VALUE, Integer.MAX_VALUE), doubleArray(Double.MIN_VALUE, Double.MAX_VALUE), shortArray(Short.MIN_VALUE, Short.MAX_VALUE), byteArray((int) Byte.MIN_VALUE, (int) Byte.MAX_VALUE), boolArray(Boolean.TRUE, Boolean.FALSE)).build();
    new RowSetComparison(expected).verifyAndClearAll(sets);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

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