Search in sources :

Example 31 with RowSetComparison

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

the class TestPdfFormat method testMetadataQuery.

@Test
public void testMetadataQuery() throws RpcException {
    String sql = "SELECT _page_count, " + "_title, " + "_author, " + "_subject, " + "_keywords, " + "_creator, " + "_producer," + "_creation_date, " + "_modification_date, " + "_trapped " + "FROM cp.`pdf/20.pdf` " + "LIMIT 1";
    QueryBuilder q = client.queryBuilder().sql(sql);
    RowSet results = q.rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("_page_count", MinorType.INT).addNullable("_title", MinorType.VARCHAR).addNullable("_author", MinorType.VARCHAR).addNullable("_subject", MinorType.VARCHAR).addNullable("_keywords", MinorType.VARCHAR).addNullable("_creator", MinorType.VARCHAR).addNullable("_producer", MinorType.VARCHAR).addNullable("_creation_date", MinorType.TIMESTAMP).addNullable("_modification_date", MinorType.TIMESTAMP).addNullable("_trapped", MinorType.VARCHAR).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow(1, "Agricultural Landuse Survey in The Sumas River Watershed Summa", "Vision", "Agricultural Landuse Survey in The Sumas River Watershed Summa", "Agricultural Landuse Survey in The Sumas River Watershed Summa", "PScript5.dll Version 5.2.2", "Acrobat Distiller 7.0.5 (Windows)", 857403000000L, 1230835135000L, null).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) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 32 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison 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);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 33 with RowSetComparison

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

the class TestPdfFormat method testProvidedSchema.

@Test
public void testProvidedSchema() throws Exception {
    String sql = "SELECT * FROM table(cp.`pdf/schools.pdf` (type => 'pdf', combinePages => true, " + "schema => 'inline=(`Last Name` VARCHAR, `First Name Address` VARCHAR, `field_0` VARCHAR, `City` " + "VARCHAR, `State` VARCHAR, `Zip` VARCHAR, `field_1` VARCHAR, `Occupation Employer` VARCHAR, " + "`Date` VARCHAR, `field_2` DATE properties {`drill.format` = `M/d/yyyy`}, `Amount` DOUBLE)')) " + "LIMIT 5";
    RowSet results = client.queryBuilder().sql(sql).rowSet();
    TupleMetadata expectedSchema = new SchemaBuilder().addNullable("Last Name", MinorType.VARCHAR).addNullable("First Name Address", MinorType.VARCHAR).addNullable("field_0", MinorType.VARCHAR).addNullable("City", MinorType.VARCHAR).addNullable("State", MinorType.VARCHAR).addNullable("Zip", MinorType.VARCHAR).addNullable("field_1", MinorType.VARCHAR).addNullable("Occupation Employer", MinorType.VARCHAR).addNullable("Date", MinorType.VARCHAR).addNullable("field_2", MinorType.DATE).addNullable("Amount", MinorType.FLOAT8).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema).addRow("Lidstad", "Dick & Peg 62 Mississippi River Blvd N", null, "Saint Paul", "MN", null, "55104", "retired", null, LocalDate.parse("2012-10-12"), 60.0).addRow("Strom", "Pam 1229 Hague Ave", null, "St. Paul", "MN", null, "55104", null, null, LocalDate.parse("2012-09-12"), 60.0).addRow("Seeba", "Louise & Paul 1399 Sheldon St", null, "Saint Paul", "MN", null, "55108", "BOE City of Saint Paul", null, LocalDate.parse("2012-10-12"), 60.0).addRow("Schumacher / Bales", "Douglas L. / Patricia 948 County Rd. D W", null, "Saint Paul", "MN", null, "55126", null, null, LocalDate.parse("2012-10-13"), 60.0).addRow("Abrams", "Marjorie 238 8th St east", null, "St Paul", "MN", null, "55101", "Retired Retired", null, LocalDate.parse("2012-08-08"), 75.0).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 34 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison 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);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 35 with RowSetComparison

use of org.apache.drill.test.rowSet.RowSetComparison 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);
}
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) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

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