Search in sources :

Example 6 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 7 with QueryBuilder

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();
}
Also used : RowSet(org.apache.drill.exec.physical.rowSet.RowSet) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 8 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 9 with QueryBuilder

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();
}
Also used : RowSet(org.apache.drill.exec.physical.rowSet.RowSet) QueryBuilder(org.apache.drill.test.QueryBuilder) Ignore(org.junit.Ignore) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 10 with QueryBuilder

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);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

QueryBuilder (org.apache.drill.test.QueryBuilder)65 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)61 Test (org.junit.Test)53 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)48 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)48 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)48 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)45 ClusterTest (org.apache.drill.test.ClusterTest)39 SlowTest (org.apache.drill.categories.SlowTest)14 SqlFunctionTest (org.apache.drill.categories.SqlFunctionTest)3 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Ignore (org.junit.Ignore)2 EvfTest (org.apache.drill.categories.EvfTest)1 SqlTest (org.apache.drill.categories.SqlTest)1 BaseCsvTest (org.apache.drill.exec.store.easy.text.compliant.BaseCsvTest)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1