use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class SecuredPhoenixSQLTest method doTestHavingPushdown.
private void doTestHavingPushdown() throws Exception {
String sql = "select n_regionkey, max(n_nationkey) from phoenix123.v1.nation group by n_regionkey having max(n_nationkey) > 20";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
builder.planMatcher().exclude("Aggregate").include("Phoenix\\(.* GROUP BY .* HAVING MAX").match();
TupleMetadata schema = new SchemaBuilder().addNullable("n_regionkey", MinorType.BIGINT).addNullable("EXPR$1", MinorType.BIGINT).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(1, 24).addRow(2, 21).addRow(3, 23).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class SecuredPhoenixSQLTest method doTestDistinctPushdown.
private void doTestDistinctPushdown() throws Exception {
// auto convert to group-by
String sql = "select distinct n_name from phoenix123.v1.nation";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
builder.planMatcher().exclude("Aggregate").include("Phoenix\\(.* GROUP BY \"N_NAME").match();
TupleMetadata schema = new SchemaBuilder().addNullable("n_name", MinorType.VARCHAR).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("ALGERIA").addRow("ARGENTINA").addRow("BRAZIL").addRow("CANADA").addRow("CHINA").addRow("EGYPT").addRow("ETHIOPIA").addRow("FRANCE").addRow("GERMANY").addRow("INDIA").addRow("INDONESIA").addRow("IRAN").addRow("IRAQ").addRow("JAPAN").addRow("JORDAN").addRow("KENYA").addRow("MOROCCO").addRow("MOZAMBIQUE").addRow("PERU").addRow("ROMANIA").addRow("RUSSIA").addRow("SAUDI ARABIA").addRow("UNITED KINGDOM").addRow("UNITED STATES").addRow("VIETNAM").build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class SecuredPhoenixSQLTest method doTestFilterPushdown.
private void doTestFilterPushdown() throws Exception {
String sql = "select * from phoenix123.v1.region where r_name = 'ASIA'";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
builder.planMatcher().exclude("Filter").include("WHERE .* = 'ASIA'").match();
TupleMetadata schema = new SchemaBuilder().addNullable("R_REGIONKEY", MinorType.BIGINT).addNullable("R_NAME", MinorType.VARCHAR).addNullable("R_COMMENT", MinorType.VARCHAR).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow(2, "ASIA", "ges. thinly even pinto beans ca").build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class SecuredPhoenixSQLTest method doTestJoinPushdown.
private void doTestJoinPushdown() throws Exception {
String sql = "select a.n_name, b.r_name from phoenix123.v1.nation a join phoenix123.v1.region b " + "on a.n_regionkey = b.r_regionkey";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
builder.planMatcher().exclude("Join").include("Phoenix\\(.* INNER JOIN").match();
TupleMetadata schema = new SchemaBuilder().addNullable("n_name", MinorType.VARCHAR).addNullable("r_name", MinorType.VARCHAR).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("ALGERIA", "AFRICA").addRow("ARGENTINA", "AMERICA").addRow("BRAZIL", "AMERICA").addRow("CANADA", "AMERICA").addRow("EGYPT", "MIDDLE EAST").addRow("ETHIOPIA", "AFRICA").addRow("FRANCE", "EUROPE").addRow("GERMANY", "EUROPE").addRow("INDIA", "ASIA").addRow("INDONESIA", "ASIA").addRow("IRAN", "MIDDLE EAST").addRow("IRAQ", "MIDDLE EAST").addRow("JAPAN", "ASIA").addRow("JORDAN", "MIDDLE EAST").addRow("KENYA", "AFRICA").addRow("MOROCCO", "AFRICA").addRow("MOZAMBIQUE", "AFRICA").addRow("PERU", "AMERICA").addRow("CHINA", "ASIA").addRow("ROMANIA", "EUROPE").addRow("SAUDI ARABIA", "MIDDLE EAST").addRow("VIETNAM", "ASIA").addRow("RUSSIA", "EUROPE").addRow("UNITED KINGDOM", "EUROPE").addRow("UNITED STATES", "AMERICA").build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class PhoenixCommandTest method testDescribeCaseInsensitive.
@Test
public void testDescribeCaseInsensitive() throws Exception {
// use lowercase
String sql = "DESCRIBE phoenix123.v1.nation";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("COLUMN_NAME", MinorType.VARCHAR).addNullable("DATA_TYPE", MinorType.VARCHAR).addNullable("IS_NULLABLE", MinorType.VARCHAR).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("N_NATIONKEY", "BIGINT", "NO").addRow("N_NAME", "CHARACTER VARYING", "YES").addRow("N_REGIONKEY", "BIGINT", "YES").addRow("N_COMMENT", "CHARACTER VARYING", "YES").build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
Aggregations