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