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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations