use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPcapngStatRecordReader method testStarQuery.
@Test
public void testStarQuery() throws Exception {
String sql = "select * from dfs.`pcapng/example.pcapng`";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
assertEquals(3, sets.rowCount());
sets.clear();
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPdfFormat method testNoHeaders.
@Test
public void testNoHeaders() throws RpcException {
String sql = "SELECT * " + "FROM table(cp.`pdf/argentina_diputados_voting_record.pdf` " + "(type => 'pdf', combinePages => false, extractHeaders => false)) WHERE field_2 = 'Rio Negro'";
QueryBuilder q = client.queryBuilder().sql(sql);
RowSet results = q.rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("field_0", MinorType.VARCHAR).addNullable("field_1", MinorType.VARCHAR).addNullable("field_2", MinorType.VARCHAR).addNullable("field_3", 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);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPdfFormat method testStarQuery.
@Test
public void testStarQuery() throws RpcException {
String sql = "SELECT * FROM cp.`pdf/argentina_diputados_voting_record.pdf` 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);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestPdfFormat method testExplicitQuery.
@Test
public void testExplicitQuery() throws RpcException {
String sql = "SELECT `Apellido y Nombre`, `Bloque político`, `Provincia`, `field_0` " + "FROM cp.`pdf/argentina_diputados_voting_record.pdf` 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);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestComplexSchemaFunctions method testMapSchemaFunctionWithNull.
@Test
public void testMapSchemaFunctionWithNull() throws RpcException {
String sql = "SELECT getMapSchema(null) AS schema FROM cp.`json/nestedSchema.json` AS t1";
QueryBuilder q = client.queryBuilder().sql(sql);
RowSet results = q.rowSet();
TupleMetadata expectedSchema = new SchemaBuilder().add("schema", MinorType.MAP).build();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow((Object) mapArray()).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
Aggregations