Search in sources :

Example 26 with BatchSchemaBuilder

use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.

the class TestImplicitFileColumns method testStarColumnParquet.

@Test
public void testStarColumnParquet() throws Exception {
    SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("dir0", TypeProtos.MinorType.VARCHAR).addNullable("dir1", TypeProtos.MinorType.VARCHAR).add("o_orderkey", TypeProtos.MinorType.INT).add("o_custkey", TypeProtos.MinorType.INT).add("o_orderstatus", TypeProtos.MinorType.VARCHAR).add("o_totalprice", TypeProtos.MinorType.FLOAT8).add("o_orderdate", TypeProtos.MinorType.DATE).add("o_orderpriority", TypeProtos.MinorType.VARCHAR).add("o_clerk", TypeProtos.MinorType.VARCHAR).add("o_shippriority", TypeProtos.MinorType.INT).add("o_comment", TypeProtos.MinorType.VARCHAR);
    final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery("select * from dfs.`%s` ", PARQUET_TBL).schemaBaseLine(expectedSchema).build().run();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) Test(org.junit.Test)

Example 27 with BatchSchemaBuilder

use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.

the class TestImplicitFileColumns method testStarColumnCsv.

@Test
public void testStarColumnCsv() throws Exception {
    SchemaBuilder schemaBuilder = new SchemaBuilder().addArray("columns", TypeProtos.MinorType.VARCHAR).addNullable("dir0", TypeProtos.MinorType.VARCHAR).addNullable("dir1", TypeProtos.MinorType.VARCHAR);
    final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery("select * from dfs.`%s` ", CSV_TBL).schemaBaseLine(expectedSchema).build().run();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) Test(org.junit.Test)

Example 28 with BatchSchemaBuilder

use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.

the class TestImplicitFileColumns method testStarColumnJson.

@Test
public void testStarColumnJson() throws Exception {
    SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("dir0", TypeProtos.MinorType.VARCHAR).addNullable("id", TypeProtos.MinorType.BIGINT).addNullable("name", TypeProtos.MinorType.VARCHAR);
    final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery("select * from dfs.`%s` ", JSON_TBL).schemaBaseLine(expectedSchema).build().run();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) Test(org.junit.Test)

Example 29 with BatchSchemaBuilder

use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.

the class TestParquetMetadataCache method testEmptyDirectoryWithMetadataFile.

@Test
public void testEmptyDirectoryWithMetadataFile() throws Exception {
    final String emptyDirNameWithMetadataFile = "empty_directory";
    dirTestWatcher.makeTestTmpSubDir(Paths.get(emptyDirNameWithMetadataFile));
    dirTestWatcher.copyResourceToTestTmp(Paths.get("parquet", "metadata_files_with_old_versions", "v3_1", "metadata_table.requires_replace.txt"), Paths.get(emptyDirNameWithMetadataFile, Metadata.OLD_METADATA_FILENAME));
    final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(new SchemaBuilder()).build();
    testBuilder().sqlQuery("select * from dfs.tmp.`%s`", emptyDirNameWithMetadataFile).schemaBaseLine(expectedSchema).build().run();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 30 with BatchSchemaBuilder

use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.

the class TestFunctionsQuery method testBooleanConditionsMode.

@Test
public void testBooleanConditionsMode() throws Exception {
    List<String> conditions = Arrays.asList("employee_id IS NULL", "employee_id IS NOT NULL", "employee_id > 0 IS TRUE", "employee_id > 0 IS NOT TRUE", "employee_id > 0 IS FALSE", "employee_id > 0 IS NOT FALSE", "employee_id IS NULL OR position_id IS NULL", "employee_id IS NULL AND position_id IS NULL", "isdate(employee_id)", "NOT (employee_id IS NULL)");
    SchemaBuilder schemaBuilder = new SchemaBuilder().add("col1", TypeProtos.MinorType.BIT);
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    for (String condition : conditions) {
        testBuilder().sqlQuery("SELECT %s AS col1 FROM cp.`employee.json` LIMIT 0", condition).schemaBaseLine(expectedSchema).go();
    }
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest)

Aggregations

BatchSchemaBuilder (org.apache.drill.exec.record.BatchSchemaBuilder)58 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)58 BatchSchema (org.apache.drill.exec.record.BatchSchema)56 Test (org.junit.Test)56 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)20 RecordBatch (org.apache.drill.exec.record.RecordBatch)14 SubOperatorTest (org.apache.drill.test.SubOperatorTest)10 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)7 PlannerTest (org.apache.drill.categories.PlannerTest)5 SqlFunctionTest (org.apache.drill.categories.SqlFunctionTest)5 MaterializedField (org.apache.drill.exec.record.MaterializedField)5 SqlTest (org.apache.drill.categories.SqlTest)4 HashJoinPOP (org.apache.drill.exec.physical.config.HashJoinPOP)4 ScanFixture (org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture)4 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)4 ClusterTest (org.apache.drill.test.ClusterTest)4 OperatorTest (org.apache.drill.categories.OperatorTest)3 ParquetTest (org.apache.drill.categories.ParquetTest)3 VectorTest (org.apache.drill.categories.VectorTest)3 ExecTest (org.apache.drill.exec.ExecTest)3