Search in sources :

Example 81 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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 82 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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 83 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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)

Example 84 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class SecuredPhoenixDataTypeTest method doTestDataType.

private void doTestDataType() throws Exception {
    String sql = "select * from phoenix123.v1.datatype";
    QueryBuilder builder = queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    TupleMetadata schema = new SchemaBuilder().addNullable("T_UUID", MinorType.VARCHAR).addNullable("T_VARCHAR", MinorType.VARCHAR).addNullable("T_CHAR", MinorType.VARCHAR).addNullable("T_BIGINT", MinorType.BIGINT).addNullable("T_INTEGER", MinorType.INT).addNullable("T_SMALLINT", MinorType.INT).addNullable("T_TINYINT", MinorType.INT).addNullable("T_DOUBLE", MinorType.FLOAT8).addNullable("T_FLOAT", MinorType.FLOAT4).addNullable("T_DECIMAL", MinorType.VARDECIMAL).addNullable("T_DATE", MinorType.DATE).addNullable("T_TIME", MinorType.TIME).addNullable("T_TIMESTAMP", MinorType.TIMESTAMP).addNullable("T_BINARY", MinorType.VARBINARY).addNullable("T_VARBINARY", MinorType.VARBINARY).addNullable("T_BOOLEAN", MinorType.BIT).build();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(U_U_I_D, "apache", "drill", Long.MAX_VALUE, Integer.MAX_VALUE, Short.MAX_VALUE, Byte.MAX_VALUE, Double.MAX_VALUE, Float.MAX_VALUE, BigDecimal.valueOf(10.11), LocalDate.parse("2021-12-12"), LocalTime.parse("12:12:12"), Instant.ofEpochMilli(1639311132000l), "a_b_c_d_e_".getBytes(), "12345".getBytes(), Boolean.TRUE).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 85 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class SecuredPhoenixDataTypeTest method doTestArrayType.

private void doTestArrayType() 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)

Aggregations

RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)303 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)296 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)293 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)288 Test (org.junit.Test)282 ClusterTest (org.apache.drill.test.ClusterTest)153 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)140 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)84 EvfTest (org.apache.drill.categories.EvfTest)64 QueryBuilder (org.apache.drill.test.QueryBuilder)45 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)28 SubOperatorTest (org.apache.drill.test.SubOperatorTest)27 QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)26 SlowTest (org.apache.drill.categories.SlowTest)23 ValueVector (org.apache.drill.exec.vector.ValueVector)23 MockResponse (okhttp3.mockwebserver.MockResponse)21 MockWebServer (okhttp3.mockwebserver.MockWebServer)21 ColumnSize (org.apache.drill.exec.record.RecordBatchSizer.ColumnSize)20 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)18 JdbcStorageTest (org.apache.drill.categories.JdbcStorageTest)17