use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestPcapngStatRecordReader method testValidHeaders.
@Test
public void testValidHeaders() throws Exception {
String sql = "select * from dfs.`pcapng/sniff.pcapng`";
RowSet sets = client.queryBuilder().sql(sql).rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("path", MinorType.VARCHAR).addNullable("shb_hardware", MinorType.VARCHAR).addNullable("shb_os", MinorType.VARCHAR).addNullable("shb_userappl", MinorType.VARCHAR).addNullable("if_name", MinorType.VARCHAR).addNullable("if_description", MinorType.VARCHAR).addNullable("if_ipv4addr", MinorType.VARCHAR).addNullable("if_ipv6addr", MinorType.VARCHAR).addNullable("if_macaddr", MinorType.VARCHAR).addNullable("if_euiaddr", MinorType.VARCHAR).addNullable("if_speed", MinorType.INT).addNullable("if_tsresol", MinorType.INT).addNullable("if_tzone", MinorType.INT).addNullable("if_os", MinorType.VARCHAR).addNullable("if_fcslen", MinorType.INT).addNullable("if_tsoffset", MinorType.INT).addNullable("ns_dnsname", MinorType.VARCHAR).addNullable("ns_dnsip4addr", MinorType.VARCHAR).addNullable("ns_dnsip6addr", MinorType.VARCHAR).addNullable("isb_starttime", MinorType.TIMESTAMP).addNullable("isb_endtime", MinorType.TIMESTAMP).addNullable("isb_ifrecv", MinorType.BIGINT).addNullable("isb_ifdrop", MinorType.BIGINT).addNullable("isb_filteraccept", MinorType.BIGINT).addNullable("isb_osdrop", MinorType.BIGINT).addNullable("isb_usrdeliv", MinorType.BIGINT).build();
RowSet expected = new RowSetBuilder(client.allocator(), schema).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
use of org.apache.drill.test.rowSet.RowSetComparison 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.rowSet.RowSetComparison 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.test.rowSet.RowSetComparison 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.test.rowSet.RowSetComparison in project drill by apache.
the class TestPdfFormat method testUnicode.
@Test
public void testUnicode() throws Exception {
String sql = "SELECT * FROM cp.`pdf/arabic.pdf`";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("مرحباً", MinorType.VARCHAR).addNullable("اسمي سلطان", MinorType.VARCHAR).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("انا من ولاية كارولينا الشمال", "من اين انت؟").addRow("1234", "عندي 47 قطط").addRow("هل انت شباك؟", "اسمي Jeremy في الانجليزية").addRow("Jeremy is جرمي in Arabic", null).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
Aggregations