Search in sources :

Example 1 with SchemaBuilder

use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.

the class TestBatchSerialization method testMap.

/**
 * Tests a map type and an SV2.
 *
 * @throws IOException
 */
@Test
public void testMap() throws IOException {
    BatchSchema schema = new SchemaBuilder().add("top", MinorType.INT).addMap("map").add("key", MinorType.INT).add("value", MinorType.VARCHAR).resumeSchema().build();
    verifySerialize(buildMapSet(schema).toIndirect(), buildMapSet(schema));
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) DrillTest(org.apache.drill.test.DrillTest) Test(org.junit.Test)

Example 2 with SchemaBuilder

use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.

the class TestEmptyInputSql method testQueryEmptyCsvH.

/**
 * Test select * against empty csv with empty header. * is expanded into empty list of fields.
 * @throws Exception
 */
@Test
public void testQueryEmptyCsvH() throws Exception {
    final BatchSchema expectedSchema = new SchemaBuilder().build();
    testBuilder().sqlQuery("select * from cp.`%s`", SINGLE_EMPTY_CSVH).schemaBaseLine(expectedSchema).build().run();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 3 with SchemaBuilder

use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.

the class TestEmptyInputSql method testQueryConstExprEmptyJson.

/**
 * Test with query against an empty file. Select clause has three expressions.
 * 1.0 + 100.0 as constant expression, is resolved to required FLOAT8
 * cast(100 as varchar(100) is resolved to required varchar(100)
 * cast(columns as varchar(100)) is resolved to nullable varchar(100).
 */
@Test
public void testQueryConstExprEmptyJson() throws Exception {
    final BatchSchema expectedSchema = new SchemaBuilder().add("key", TypeProtos.MinorType.FLOAT8).add("name", TypeProtos.MinorType.VARCHAR, 100).addNullable("name2", TypeProtos.MinorType.VARCHAR, 100).build();
    testBuilder().sqlQuery("select 1.0 + 100.0 as key, " + " cast(100 as varchar(100)) as name, " + " cast(columns as varchar(100)) as name2 " + " from cp.`%s` ", SINGLE_EMPTY_JSON).schemaBaseLine(expectedSchema).build().run();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 4 with SchemaBuilder

use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.

the class TestEmptyInputSql method testEmptyDirectory.

@Test
public void testEmptyDirectory() throws Exception {
    final BatchSchema expectedSchema = 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) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 5 with SchemaBuilder

use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.

the class TestEmptyInputSql method testQueryMapArrayEmptyJson.

@Test
public void testQueryMapArrayEmptyJson() throws Exception {
    final BatchSchema expectedSchema = new SchemaBuilder().addNullable("col1", TypeProtos.MinorType.INT).addNullable("col2", TypeProtos.MinorType.INT).addNullable("col3", TypeProtos.MinorType.INT).build();
    testBuilder().sqlQuery("select foo.a.b as col1, foo.columns[2] as col2, foo.bar.columns[3] as col3 from cp.`%s` as foo", SINGLE_EMPTY_JSON).schemaBaseLine(expectedSchema).build().run();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Aggregations

SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)175 Test (org.junit.Test)154 BatchSchema (org.apache.drill.exec.record.BatchSchema)102 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)91 SubOperatorTest (org.apache.drill.test.SubOperatorTest)86 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)65 RowSet (org.apache.drill.test.rowSet.RowSet)52 RowSetReader (org.apache.drill.test.rowSet.RowSetReader)50 ResultSetLoader (org.apache.drill.exec.physical.rowSet.ResultSetLoader)38 RowSetLoader (org.apache.drill.exec.physical.rowSet.RowSetLoader)38 ScalarReader (org.apache.drill.exec.vector.accessor.ScalarReader)26 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)25 DrillTest (org.apache.drill.test.DrillTest)21 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)20 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)18 RowSetBuilder (org.apache.drill.test.rowSet.RowSetBuilder)18 ScalarElementReader (org.apache.drill.exec.vector.accessor.ScalarElementReader)17 AbstractColumnMetadata (org.apache.drill.exec.record.metadata.AbstractColumnMetadata)16 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)16 RecordBatch (org.apache.drill.exec.record.RecordBatch)14