Search in sources :

Example 6 with BatchSchemaBuilder

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

the class TestEmptyInputSql method testRenameProjectEmptyDirectory.

@Test
public void testRenameProjectEmptyDirectory() throws Exception {
    SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("WeekId", TypeProtos.MinorType.INT).addNullable("ProductName", TypeProtos.MinorType.INT);
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery("select WeekId, Product as ProductName from (select CAST(`dir0` as INT) AS WeekId, " + "Product from dfs.tmp.`%s`)", EMPTY_DIR_NAME).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) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 7 with BatchSchemaBuilder

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

the class TestEmptyInputSql method testQueryStarColEmptyJson.

/**
 * Test with query against an empty file. Select clause has one or more *
 * star column is expanded into an empty list.
 */
@Test
public void testQueryStarColEmptyJson() throws Exception {
    final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(new SchemaBuilder()).build();
    testBuilder().sqlQuery("select * from cp.`%s` ", SINGLE_EMPTY_JSON).schemaBaseLine(expectedSchema).build().run();
    testBuilder().sqlQuery("select *, * from cp.`%s` ", SINGLE_EMPTY_JSON).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 8 with BatchSchemaBuilder

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

the class TestEmptyInputSql method testEmptyDirectoryAndFieldInQuery.

@Test
public void testEmptyDirectoryAndFieldInQuery() throws Exception {
    SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("key", TypeProtos.MinorType.INT);
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery("select key from dfs.tmp.`%s`", EMPTY_DIR_NAME).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) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 9 with BatchSchemaBuilder

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

the class TestEmptyInputSql method testQueryEmptyJson.

/**
 * Test with query against an empty file. Select clause has regular column
 * reference, and an expression.
 * <p>
 * regular column "key" is assigned with nullable-int
 * expression "key + 100" is materialized with nullable-int as output type.
 */
@Test
public void testQueryEmptyJson() throws Exception {
    SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("key", TypeProtos.MinorType.INT).addNullable("key2", TypeProtos.MinorType.INT);
    final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery("select key, key + 100 as key2 from cp.`%s`", SINGLE_EMPTY_JSON).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) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 10 with BatchSchemaBuilder

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

the class TestEmptyInputSql method testEmptyDirectory.

@Test
public void testEmptyDirectory() throws Exception {
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(new SchemaBuilder()).build();
    testBuilder().sqlQuery("select * from dfs.tmp.`%s`", EMPTY_DIR_NAME).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)

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