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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations