Search in sources :

Example 21 with BatchSchemaBuilder

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

the class TestHiveStructs method testCorrectColumnOrdering.

// DRILL-7429
@Test
public void testCorrectColumnOrdering() throws Exception {
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(new SchemaBuilder().addMap("a").resumeSchema().addNullable("b", TypeProtos.MinorType.INT)).build();
    String sql = "SELECT t.str_n0 a, rid b FROM hive.struct_tbl t LIMIT 1";
    testBuilder().sqlQuery(sql).schemaBaseLine(expectedSchema).go();
}
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) HiveStorageTest(org.apache.drill.categories.HiveStorageTest) HiveClusterTest(org.apache.drill.exec.hive.HiveClusterTest) SlowTest(org.apache.drill.categories.SlowTest) Test(org.junit.Test)

Example 22 with BatchSchemaBuilder

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

the class TestStarQueries method testSchemaForParallelizedStarOrderBy.

// DRILL-5822
@Test
public void testSchemaForParallelizedStarOrderBy() throws Exception {
    String query = "select * from cp.`tpch/region.parquet` order by r_name";
    SchemaBuilder schemaBuilder = new SchemaBuilder().add("r_regionkey", TypeProtos.MinorType.INT).add("r_name", TypeProtos.MinorType.VARCHAR).add("r_comment", TypeProtos.MinorType.VARCHAR);
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery(query).optionSettingQueriesForTestQuery("alter session set `planner.slice_target`=1").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) PlannerTest(org.apache.drill.categories.PlannerTest) SqlTest(org.apache.drill.categories.SqlTest)

Example 23 with BatchSchemaBuilder

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

the class TestUntypedNull method testCoalesceOnNotExistentColumns.

@Test
public void testCoalesceOnNotExistentColumns() throws Exception {
    String query = "select coalesce(unk1, unk2) as coal from cp.`tpch/nation.parquet` limit 5";
    SchemaBuilder schemaBuilder = new SchemaBuilder().add("coal", UNTYPED_NULL_TYPE);
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery(query).schemaBaseLine(expectedSchema).go();
    testBuilder().sqlQuery(query).unOrdered().baselineColumns("coal").baselineValuesForSingleColumn(null, null, null, null, null).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) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest)

Example 24 with BatchSchemaBuilder

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

the class TestUntypedNull method testCoalesceOnNotExistentColumnsWithOrderBy.

@Test
public void testCoalesceOnNotExistentColumnsWithOrderBy() throws Exception {
    String query = "select coalesce(unk1, unk2) as coal from cp.`tpch/nation.parquet` order by 1 limit 5";
    SchemaBuilder schemaBuilder = new SchemaBuilder().add("coal", UNTYPED_NULL_TYPE);
    BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
    testBuilder().sqlQuery(query).schemaBaseLine(expectedSchema).go();
    testBuilder().sqlQuery(query).unOrdered().baselineColumns("coal").baselineValuesForSingleColumn(null, null, null, null, null).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) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest)

Example 25 with BatchSchemaBuilder

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

the class AbstractGenericCopierTest method createTestSchema.

protected BatchSchema createTestSchema(BatchSchema.SelectionVectorMode mode) {
    MaterializedField colA = MaterializedField.create("colA", Types.required(TypeProtos.MinorType.INT));
    MaterializedField colB = MaterializedField.create("colB", Types.required(TypeProtos.MinorType.VARCHAR));
    MaterializedField colC = MaterializedField.create("colC", Types.repeated(TypeProtos.MinorType.FLOAT4));
    MaterializedField colD = MaterializedField.create("colD", Types.repeated(TypeProtos.MinorType.VARCHAR));
    SchemaBuilder schemaBuilder = new SchemaBuilder().add(colA).add(colB).add(colC).add(colD);
    return new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).withSVMode(mode).build();
}
Also used : SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) MaterializedField(org.apache.drill.exec.record.MaterializedField)

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