use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestXMLReader method testWildcard.
/**
* This unit test tests a simple XML file with no nesting or attributes
* @throws Exception Throw exception if anything goes wrong
*/
@Test
public void testWildcard() throws Exception {
String sql = "SELECT * FROM cp.`xml/simple.xml`";
RowSet results = client.queryBuilder().sql(sql).rowSet();
assertEquals(3, results.rowCount());
TupleMetadata expectedSchema = new SchemaBuilder().add("attributes", MinorType.MAP).addNullable("groupID", MinorType.VARCHAR).addNullable("artifactID", MinorType.VARCHAR).addNullable("version", MinorType.VARCHAR).addNullable("classifier", MinorType.VARCHAR).addNullable("scope", MinorType.VARCHAR).buildSchema();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow(mapArray(), "org.apache.drill.exec", "drill-java-exec", "${project.version}", null, null).addRow(mapArray(), "org.apache.drill.exec", "drill-java-exec", "${project.version}", "tests", "test").addRow(mapArray(), "org.apache.drill", "drill-common", "${project.version}", "tests", "test").build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestXMLReader method testExplicitWithSingleNestedDataField.
@Test
public void testExplicitWithSingleNestedDataField() throws Exception {
String sql = "SELECT t1.field1.key1 as key1, t1.field1.key2 as key2 FROM cp.`xml/really-simple-nested.xml` as t1";
RowSet results = client.queryBuilder().sql(sql).rowSet();
assertEquals(3, results.rowCount());
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("key1", MinorType.VARCHAR).addNullable("key2", MinorType.VARCHAR).buildSchema();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow("value1", "value2").addRow("value3", "value4").addRow("value5", "value6").build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestXMLReader method testComplexNestedExplicit.
@Test
public void testComplexNestedExplicit() throws Exception {
String sql = "SELECT xml.field2.nestedField1.nk1 as nk1, xml.field2.nestedField1.nk2 as nk2, xml.field2.nestedField1.nk3 as nk3 FROM cp.`xml/nested.xml` AS xml";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("nk1", MinorType.VARCHAR).addNullable("nk2", MinorType.VARCHAR).addNullable("nk3", MinorType.VARCHAR).build();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow("nk_value1", "nk_value2", "nk_value3").addRow("nk_value4", "nk_value5", "nk_value6").addRow("nk_value7", "nk_value8", "nk_value9").build();
assertEquals(3, results.rowCount());
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestXMLReader method testWildcardWithSingleNestedDataField.
@Test
public void testWildcardWithSingleNestedDataField() throws Exception {
String sql = "SELECT * FROM cp.`xml/really-simple-nested.xml`";
RowSet results = client.queryBuilder().sql(sql).rowSet();
assertEquals(3, results.rowCount());
TupleMetadata expectedSchema = new SchemaBuilder().add("attributes", MinorType.MAP, DataMode.REQUIRED).addMap("field1").addNullable("key1", MinorType.VARCHAR).addNullable("key2", MinorType.VARCHAR).resumeSchema().buildSchema();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow(mapArray(), strArray("value1", "value2")).addRow(mapArray(), strArray("value3", "value4")).addRow(mapArray(), strArray("value5", "value6")).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.rowSet.RowSetComparison in project drill by apache.
the class TestXMLReader method testNestedAttributes.
@Test
public void testNestedAttributes() throws Exception {
String sql = "SELECT * FROM cp.`xml/nested-with-attributes.xml`";
RowSet results = client.queryBuilder().sql(sql).rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addMap("attributes").addNullable("field1_f1", MinorType.VARCHAR).addNullable("field2_f2", MinorType.VARCHAR).addNullable("field2_key3_f3", MinorType.VARCHAR).addNullable("field2_nestedField1_f4", MinorType.VARCHAR).addNullable("field2_nestedField1_f5", MinorType.VARCHAR).addNullable("field2_nestedField1_nk1_f6", MinorType.VARCHAR).addNullable("field2_nestedField1_nk1_f7", MinorType.VARCHAR).addNullable("field2_nestedField1_nk3_f8", MinorType.VARCHAR).resumeSchema().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(strArray("k1", "k2", "k3", "k4", "k5", "k6", "k7", null), strArray("value1", "value2"), objArray("k1", strArray("nk_value1", "nk_value2", "nk_value3"))).addRow(strArray(null, null, null, null, null, null, null, null), strArray("value3", "value4"), objArray("k2", strArray("nk_value4", "nk_value5", "nk_value6"))).addRow(strArray(null, null, null, null, null, null, null, "k8"), strArray("value5", "value6"), objArray("k3", strArray("nk_value7", "nk_value8", "nk_value9"))).build();
assertEquals(3, results.rowCount());
new RowSetComparison(expected).verifyAndClearAll(results);
}
Aggregations