Search in sources :

Example 61 with RowSet

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);
}
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 62 with RowSet

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();
}
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 63 with RowSet

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

Example 64 with RowSet

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

Example 65 with RowSet

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

Aggregations

RowSet (org.apache.drill.exec.physical.rowSet.RowSet)725 Test (org.junit.Test)690 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)583 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)574 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)297 ClusterTest (org.apache.drill.test.ClusterTest)253 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)233 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)137 SubOperatorTest (org.apache.drill.test.SubOperatorTest)128 JsonTest (org.apache.drill.categories.JsonTest)112 EvfTest (org.apache.drill.categories.EvfTest)107 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)97 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)63 ResultSetLoader (org.apache.drill.exec.physical.resultSet.ResultSetLoader)61 QueryBuilder (org.apache.drill.test.QueryBuilder)61 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)60 OperatorTest (org.apache.drill.categories.OperatorTest)53 VectorContainer (org.apache.drill.exec.record.VectorContainer)31 RowBatchReader (org.apache.drill.exec.physical.impl.scan.RowBatchReader)28 QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)27