use of org.apache.drill.exec.physical.rowSet.RowSet 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.exec.physical.rowSet.RowSet 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.exec.physical.rowSet.RowSet in project drill by apache.
the class TestXMLReader method testComplexWildcardStar.
@Test
public void testComplexWildcardStar() throws Exception {
String sql = "SELECT * FROM cp.`xml/nested.xml`";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("attributes", MinorType.MAP, DataMode.REQUIRED).addMap("field1").addNullable("key1", MinorType.VARCHAR).addNullable("key2", MinorType.VARCHAR).resumeSchema().addMap("field2").addNullable("key3", MinorType.VARCHAR).addMap("nestedField1").addNullable("nk1", MinorType.VARCHAR).addNullable("nk2", MinorType.VARCHAR).addNullable("nk3", MinorType.VARCHAR).resumeMap().resumeSchema().buildSchema();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow(mapArray(), strArray("value1", "value2"), objArray("k1", strArray("nk_value1", "nk_value2", "nk_value3"))).addRow(mapArray(), strArray("value3", "value4"), objArray("k2", strArray("nk_value4", "nk_value5", "nk_value6"))).addRow(mapArray(), strArray("value5", "value6"), objArray("k3", strArray("nk_value7", "nk_value8", "nk_value9"))).build();
assertEquals(3, results.rowCount());
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.exec.physical.rowSet.RowSet in project drill by apache.
the class TestXMLReader method testExplicitDataLevel.
@Test
public void testExplicitDataLevel() throws Exception {
String sql = "SELECT field1, field2, field3 FROM table(cp.`xml/deep-nested2.xml` (type => 'xml', dataLevel => 8))";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("field1", MinorType.VARCHAR).addNullable("field2", MinorType.VARCHAR).addNullable("field3", MinorType.VARCHAR).build();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow("f4", "f5", "f6").addRow("f1", "f2", "f3").build();
assertEquals(2, results.rowCount());
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.exec.physical.rowSet.RowSet in project drill by apache.
the class TestPdfFormat method testFullScan.
@Test
public void testFullScan() throws Exception {
String sql = "SELECT * " + "FROM table(cp.`pdf/argentina_diputados_voting_record.pdf` " + "(type => 'pdf', combinePages => false, extractHeaders => false))";
RowSet results = client.queryBuilder().sql(sql).rowSet();
assertEquals(31, results.rowCount());
results.clear();
sql = "SELECT * " + "FROM table(cp.`pdf/argentina_diputados_voting_record.pdf` " + "(type => 'pdf', combinePages => false, extractHeaders => true))";
results = client.queryBuilder().sql(sql).rowSet();
assertEquals(31, results.rowCount());
results.clear();
}
Aggregations