Search in sources :

Example 36 with QueryBuilder

use of org.apache.drill.test.QueryBuilder in project drill by apache.

the class TestPcapngRecordReader method testExplicitQueryWithCompressedFile.

@Test
public void testExplicitQueryWithCompressedFile() throws Exception {
    QueryTestUtil.generateCompressedFile("pcapng/sniff.pcapng", "zip", "pcapng/sniff.pcapng.zip");
    String sql = "select type, packet_length, `timestamp` from dfs.`pcapng/sniff.pcapng.zip` 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) RowSetTest(org.apache.drill.categories.RowSetTest)

Example 37 with QueryBuilder

use of org.apache.drill.test.QueryBuilder in project drill by apache.

the class TestPcapngRecordReader method testGroupBy.

@Test
public void testGroupBy() throws Exception {
    String sql = "select src_ip, count(1), sum(packet_length) from dfs.`pcapng/sniff.pcapng` group by src_ip";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    assertEquals(47, 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) RowSetTest(org.apache.drill.categories.RowSetTest)

Example 38 with QueryBuilder

use of org.apache.drill.test.QueryBuilder in project drill by apache.

the class TestPcapngRecordReader method testCaseInsensitiveQuery.

@Test
public void testCaseInsensitiveQuery() throws Exception {
    String sql = "select `timestamp`, paCket_dAta, TyPe from dfs.`pcapng/sniff.pcapng`";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    assertEquals(123, 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) RowSetTest(org.apache.drill.categories.RowSetTest)

Example 39 with QueryBuilder

use of org.apache.drill.test.QueryBuilder in project drill by apache.

the class TestPcapngRecordReader method testStarQuery.

@Test
public void testStarQuery() throws Exception {
    String sql = "select * from dfs.`pcapng/sniff.pcapng`";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    assertEquals(123, 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) RowSetTest(org.apache.drill.categories.RowSetTest)

Example 40 with QueryBuilder

use of org.apache.drill.test.QueryBuilder in project drill by apache.

the class TestPcapngRecordReader method testLimitPushdown.

@Test
public void testLimitPushdown() throws Exception {
    String sql = "select * from dfs.`pcapng/sniff.pcapng` where type = 'UDP' limit 10 offset 65";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    assertEquals(6, 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) RowSetTest(org.apache.drill.categories.RowSetTest)

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 RowSetTest (org.apache.drill.categories.RowSetTest)44 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