use of org.apache.drill.test.QueryBuilder 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);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestComplexSchemaFunctions method testMapSchemaFunctionWithInnerMap.
@Test
public void testMapSchemaFunctionWithInnerMap() throws RpcException {
String sql = "SELECT getMapSchema(t1.record.map) AS schema FROM cp.`json/nestedSchema.json` AS t1";
QueryBuilder q = client.queryBuilder().sql(sql);
RowSet results = q.rowSet();
assertEquals(results.rowCount(), 1);
TupleMetadata expectedSchema = new SchemaBuilder().addMap("schema").addNullable("nested_int_field", MinorType.VARCHAR).addNullable("nested_double_field", MinorType.VARCHAR).addNullable("nested_string_field", MinorType.VARCHAR).resumeSchema().build();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow((Object) strArray("BIGINT", "FLOAT8", "VARCHAR")).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestComplexSchemaFunctions method testMapSchemaFunction.
@Test
public void testMapSchemaFunction() throws RpcException {
String sql = "SELECT getMapSchema(record) AS schema FROM cp.`json/nestedSchema.json`";
QueryBuilder q = client.queryBuilder().sql(sql);
RowSet results = q.rowSet();
assertEquals(results.rowCount(), 1);
TupleMetadata expectedSchema = new SchemaBuilder().addMap("schema").addNullable("int_field", MinorType.VARCHAR).addNullable("double_field", MinorType.VARCHAR).addNullable("string_field", MinorType.VARCHAR).addNullable("boolean_field", MinorType.VARCHAR).addNullable("int_list", MinorType.VARCHAR).addNullable("double_list", MinorType.VARCHAR).addNullable("boolean_list", MinorType.VARCHAR).addNullable("map", MinorType.VARCHAR).addNullable("repeated_map", MinorType.VARCHAR).resumeSchema().build();
RowSet expected = client.rowSetBuilder(expectedSchema).addRow((Object) strArray("BIGINT", "FLOAT8", "VARCHAR", "BIT", "REPEATED_BIGINT", "REPEATED_FLOAT8", "REPEATED_BIT", "MAP", "REPEATED_MAP")).build();
new RowSetComparison(expected).verifyAndClearAll(results);
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestFilesTable method testShowFilesForSpecificDirectory.
@Test
public void testShowFilesForSpecificDirectory() throws Exception {
try {
client.alterSession(ExecConstants.LIST_FILES_RECURSIVELY, false);
QueryBuilder queryBuilder = client.queryBuilder().sql("show files in dfs.`files`.folder1");
QueryBuilder.QuerySummary querySummary = queryBuilder.run();
assertTrue(querySummary.succeeded());
assertEquals(2, querySummary.recordCount());
// option has no effect
client.alterSession(ExecConstants.LIST_FILES_RECURSIVELY, true);
querySummary = queryBuilder.run();
assertTrue(querySummary.succeeded());
assertEquals(2, querySummary.recordCount());
} finally {
client.resetSession(ExecConstants.LIST_FILES_RECURSIVELY);
}
}
use of org.apache.drill.test.QueryBuilder in project drill by apache.
the class TestLogReaderIssue method testIssue7853UseValidDatetimeFormat.
@Test
public void testIssue7853UseValidDatetimeFormat() throws Exception {
String sql = "SELECT type, `time` FROM `dfs.data`.`root/issue7853.log`";
QueryBuilder builder = client.queryBuilder().sql(sql);
RowSet sets = builder.rowSet();
TupleMetadata schema = new SchemaBuilder().addNullable("type", MinorType.VARCHAR).addNullable("time", MinorType.TIMESTAMP).buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("h2", 1611446100664L).addRow("h2", 1611446100666L).build();
new RowSetComparison(expected).verifyAndClearAll(sets);
}
Aggregations