use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestSyslogFormat method testNonComplexFieldsWithCompressedFile.
@Test
public void testNonComplexFieldsWithCompressedFile() throws Exception {
generateCompressedFile("syslog/logs.syslog", "zip", "syslog/logs.syslog.zip");
String sql = "SELECT event_date," + "severity_code," + "severity," + "facility_code," + "facility," + "ip," + "process_id," + "message_id," + "structured_data_text " + "FROM dfs.`syslog/logs.syslog.zip`";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("event_date", TypeProtos.MinorType.TIMESTAMP, TypeProtos.DataMode.OPTIONAL).add("severity_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("severity", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("facility_code", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("facility", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("ip", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("process_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("message_id", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).add("structured_data_text", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1065910455003L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(482196050520L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(482196050520L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(1065910455003L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(1061727255000L, 2, "CRIT", 4, "AUTH", "mymachine.example.com", null, "ID47", null).addRow(1061727255000L, 5, "NOTICE", 20, "LOCAL4", "192.0.2.1", "8710", null, null).addRow(1065910455003L, 5, "NOTICE", 20, "LOCAL4", "mymachine.example.com", null, "ID47", "{examplePriority@32473=[class=high], exampleSDID@32473=[iut=3, " + "eventSource=Application, eventID=1011]}").addRow(1065910455003L, 5, "NOTICE", 20, "LOCAL4", "mymachine.example.com", null, "ID47", "{examplePriority@32473=[class=high], exampleSDID@32473=[iut=3, " + "eventSource=Application, eventID=1011]}").build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class PhoenixSQLTest method testHavingPushdown.
@Test
public void testHavingPushdown() 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.rowSet.RowSetComparison in project drill by apache.
the class PhoenixSQLTest method testDistinctPushdown.
@Test
public void testDistinctPushdown() 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.rowSet.RowSetComparison in project drill by apache.
the class PhoenixSQLTest method testLimitPushdown.
@Test
public void testLimitPushdown() 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);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class PhoenixSQLTest method testJoinPushdown.
@Test
public void testJoinPushdown() 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);
}
Aggregations