Search in sources :

Example 46 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestXMLReader method testMapError.

@Test
public void testMapError() throws Exception {
    String sql = "SELECT * FROM cp.`xml/schemaChange.xml`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addMap("attributes").resumeSchema().addMap("parent").addNullable("link", MinorType.VARCHAR).addNullable("value", MinorType.VARCHAR).resumeSchema().build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow(mapArray(), mapArray(null, null)).addRow(mapArray(), strArray("https://dev57595.service-now.com/api/now/table/task/46eaa7c9a9fe198100bbe282da0d4b7d", "46eaa7c9a9fe198100bbe282da0d4b7d")).build();
    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 47 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestXMLReader method testDataLevel.

@Test
public void testDataLevel() throws Exception {
    String sql = "SELECT * FROM table(cp.`xml/deep-nested2.xml` (type => 'xml', dataLevel => 8))";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().add("attributes", MinorType.MAP, DataMode.REQUIRED).addNullable("field1", MinorType.VARCHAR).addNullable("field2", MinorType.VARCHAR).addNullable("field3", MinorType.VARCHAR).addNullable("field1-level6", MinorType.VARCHAR).build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow(mapArray(), "f4", "f5", "f6", null).addRow(mapArray(), "f1", "f2", "f3", "l6").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 48 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestXMLReader method testDeepNesting.

@Test
public void testDeepNesting() throws Exception {
    String sql = "SELECT * FROM cp.`xml/deep-nested.xml`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    assertEquals(2, results.rowCount());
    TupleMetadata expectedSchema = new SchemaBuilder().add("attributes", MinorType.MAP, DataMode.REQUIRED).addMap("level2").addNullable("field1-level2", MinorType.VARCHAR).addMap("level3").addNullable("field1-level3", MinorType.VARCHAR).addMap("level4").addNullable("field1-level4", MinorType.VARCHAR).addMap("level5").addNullable("field1-level5", MinorType.VARCHAR).addMap("level6").addNullable("field1-level6", MinorType.VARCHAR).addMap("level7").addNullable("field1", MinorType.VARCHAR).addNullable("field2", MinorType.VARCHAR).addNullable("field3", MinorType.VARCHAR).resumeMap().resumeMap().resumeMap().resumeMap().resumeMap().resumeSchema().build();
    RowSet expected = client.rowSetBuilder(expectedSchema).addRow(mapArray(), objArray(objArray("l2", objArray("l3", objArray("l4", objArray("l5", objArray("l6", strArray("f1", "f2", "f3")))))))).addRow(mapArray(), objArray(objArray(null, objArray(null, objArray(null, objArray(null, objArray(null, strArray("f4", "f5", "f6")))))))).build();
    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 49 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestSasReader method testMetadataColumns.

@Test
public void testMetadataColumns() throws Exception {
    String sql = "SELECT _compression_method, _file_label, _file_type, " + "_os_name, _os_type, _sas_release, _session_encoding, _server_type, " + "_date_created, _date_modified FROM cp.`sas/date_formats.sas7bdat`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("_compression_method", MinorType.VARCHAR).addNullable("_file_label", MinorType.VARCHAR).addNullable("_file_type", MinorType.VARCHAR).addNullable("_os_name", MinorType.VARCHAR).addNullable("_os_type", MinorType.VARCHAR).addNullable("_sas_release", MinorType.VARCHAR).addNullable("_session_encoding", MinorType.VARCHAR).addNullable("_server_type", MinorType.VARCHAR).addNullable("_date_created", MinorType.DATE).addNullable("_date_modified", MinorType.DATE).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(null, "DATA", null, null, "9.0401M4", null, "X64_7PRO", null, LocalDate.parse("2017-03-14"), LocalDate.parse("2017-03-14")).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 50 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.

the class TestSasReader method testDates.

@Test
public void testDates() throws Exception {
    String sql = "SELECT b8601da, e8601da, `date` FROM cp.`sas/date_formats.sas7bdat`";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("b8601da", MinorType.DATE).addNullable("e8601da", MinorType.DATE).addNullable("date", MinorType.DATE).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(LocalDate.parse("2017-03-14"), LocalDate.parse("2017-03-14"), LocalDate.parse("2017-03-14")).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)

Aggregations

RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)289 Test (org.junit.Test)271 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)232 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)211 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)191 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)142 ClusterTest (org.apache.drill.test.ClusterTest)138 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)54 SubOperatorTest (org.apache.drill.test.SubOperatorTest)53 QueryBuilder (org.apache.drill.test.QueryBuilder)48 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)42 OperatorTest (org.apache.drill.categories.OperatorTest)38 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)29 RowSet (org.apache.drill.test.rowSet.RowSet)26 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)26 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)25 StreamingAggregate (org.apache.drill.exec.physical.config.StreamingAggregate)19 StreamingAggBatch (org.apache.drill.exec.physical.impl.aggregate.StreamingAggBatch)19 RowSetLoader (org.apache.drill.exec.physical.rowSet.RowSetLoader)18 BatchSchema (org.apache.drill.exec.record.BatchSchema)18