Search in sources :

Example 26 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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);
}
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) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 27 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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 28 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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);
}
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) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 29 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder 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)

Example 30 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestPdfFormat method testWithCompressedFile.

@Test
public void testWithCompressedFile() throws Exception {
    generateCompressedFile("pdf/argentina_diputados_voting_record.pdf", "zip", "pdf/compressed.pdf.zip");
    String sql = "SELECT * FROM dfs.`pdf/compressed.pdf.zip` WHERE `Provincia` = 'Rio Negro'";
    QueryBuilder q = client.queryBuilder().sql(sql);
    RowSet results = q.rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("Apellido y Nombre", MinorType.VARCHAR).addNullable("Bloque político", MinorType.VARCHAR).addNullable("Provincia", MinorType.VARCHAR).addNullable("field_0", MinorType.VARCHAR).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("ALBRIEU, Oscar Edmundo Nicolas", "Frente para la Victoria - PJ", "Rio Negro", "AFIRMATIVO").addRow("AVOSCAN, Herman Horacio", "Frente para la Victoria - PJ", "Rio Negro", "AFIRMATIVO").addRow("CEJAS, Jorge Alberto", "Frente para la Victoria - PJ", "Rio Negro", "AFIRMATIVO").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

RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)303 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)296 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)293 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)288 Test (org.junit.Test)282 ClusterTest (org.apache.drill.test.ClusterTest)153 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)140 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)84 EvfTest (org.apache.drill.categories.EvfTest)64 QueryBuilder (org.apache.drill.test.QueryBuilder)45 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)28 SubOperatorTest (org.apache.drill.test.SubOperatorTest)27 QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)26 SlowTest (org.apache.drill.categories.SlowTest)23 ValueVector (org.apache.drill.exec.vector.ValueVector)23 MockResponse (okhttp3.mockwebserver.MockResponse)21 MockWebServer (okhttp3.mockwebserver.MockWebServer)21 ColumnSize (org.apache.drill.exec.record.RecordBatchSizer.ColumnSize)20 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)18 JdbcStorageTest (org.apache.drill.categories.JdbcStorageTest)17