use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPcapngStatRecordReader method testExplicitQuery.
@Test
public void testExplicitQuery() throws Exception {
String sql = "select path, shb_hardware, shb_os, if_name, isb_ifrecv from dfs.`pcapng/sniff.pcapng`";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("path", MinorType.VARCHAR).addNullable("shb_hardware", MinorType.VARCHAR).addNullable("shb_os", MinorType.VARCHAR).addNullable("if_name", MinorType.VARCHAR).addNullable("isb_ifrecv", MinorType.BIGINT).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("sniff.pcapng", "Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (with SSE4.2)", "Mac OS X 10.13.3, build 17D47 (Darwin 17.4.0)", null, null).addRow("sniff.pcapng", null, null, "en0", null).addRow("sniff.pcapng", null, null, null, 123).build();
assertEquals(3, sets.rowCount());
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPcapngRecordReader method testDistinctQuery.
@Test
public void testDistinctQuery() throws Exception {
String sql = "select distinct `timestamp`, src_ip from dfs.`pcapng/sniff.pcapng`";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
assertEquals(119, sets.rowCount());
sets.clear();
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPcapngRecordReader method testExplicitQuery.
@Test
public void testExplicitQuery() throws Exception {
String sql = "select type, packet_length, `timestamp` from dfs.`pcapng/sniff.pcapng` where type = 'ARP'";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("type", MinorType.VARCHAR).add("packet_length", MinorType.INT).add("timestamp", MinorType.TIMESTAMP).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("ARP", 90, Instant.ofEpochMilli(1518010669927L)).addRow("ARP", 90, Instant.ofEpochMilli(1518010671874L)).build();
assertEquals(2, sets.rowCount());
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPcapngRecordReader method testPcapNG.
@Test
// todo: infinite loop with current PcapNGReader
@Ignore
public void testPcapNG() throws Exception {
// String sql = "select * from dfs.`todo/dhcp_big_endian.pcapng` limit 1"; // Bad magic number = 000a0a0a
// String sql = "select * from dfs.`todo/dhcp_little_endian.pcapng` limit 1"; // Bad magic number = 1c0a0a0a
// String sql = "select * from dfs.`todo/many_interfaces.pcapng` limit 1"; // Bad magic number = ef0a0a0a
// Bad magic number = 1c0a0a0a
String sql = "select * from dfs.`todo/mac2.pcap` limit 1";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
assertEquals(1, sets.rowCount());
sets.clear();
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPdfFormat method testMetadataQuery.
@Test
public void testMetadataQuery() throws RpcException {
String sql = "SELECT _page_count, " + "_title, " + "_author, " + "_subject, " + "_keywords, " + "_creator, " + "_producer," + "_creation_date, " + "_modification_date, " + "_trapped " + "FROM cp.`pdf/20.pdf` " + "LIMIT 1";
QueryBuilder q = client.queryBuilder().sql(sql);
RowSet results = q.rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("_page_count", MinorType.INT).addNullable("_title", MinorType.VARCHAR).addNullable("_author", MinorType.VARCHAR).addNullable("_subject", MinorType.VARCHAR).addNullable("_keywords", MinorType.VARCHAR).addNullable("_creator", MinorType.VARCHAR).addNullable("_producer", MinorType.VARCHAR).addNullable("_creation_date", MinorType.TIMESTAMP).addNullable("_modification_date", MinorType.TIMESTAMP).addNullable("_trapped", MinorType.VARCHAR).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1, "Agricultural Landuse Survey in The Sumas River Watershed Summa", "Vision", "Agricultural Landuse Survey in The Sumas River Watershed Summa", "Agricultural Landuse Survey in The Sumas River Watershed Summa", "PScript5.dll Version 5.2.2", "Acrobat Distiller 7.0.5 (Windows)", 857403000000L, 1230835135000L, null).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
Aggregations