Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
Drill has provided a test framework to submit SQL statements and verify the query results against expected results. For instance
final String query = "select n_nationkey, n_regionkey from cp.`tpch/nation.parquet` where n_nationkey = 5 and n_regionkey = 0"; testBuilder() .sqlQuery(query) .unOrdered() .baselineColumns("n_nationkey", "n_regionkey") .baselineValues(5, 0) .build() .run();
However, it seems that the test framework only do result match based on column name, without enforcing the column order in the output result set. The missing of column order verification may be different from what people typically expect, and hide some code bugs.
The following test specify the expected output columns in a reverse order. However, the current test framework would still pass the test.
final String query = "select n_nationkey, n_regionkey from cp.`tpch/nation.parquet` where n_nationkey = 5 and n_regionkey = 0"; testBuilder() .sqlQuery(query) .unOrdered() .baselineColumns("n_regionkey", "n_nationkey") .baselineValues(0, 5) .build() .run();
For now, to check the column order in query output, people should use SchemaTestBuilder. The problem is SchemaTestBuilder only allows to verify schema, without allowing to specify base line values. This means people has to write two tests if they want to verify schema & values.
final List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList( Pair.of(SchemaPath.getSimplePath("n_nationkey"), Types.required(TypeProtos.MinorType.INT)), Pair.of(SchemaPath.getSimplePath("n_regionkey"), Types.required(TypeProtos.MinorType.INT))); testBuilder() .sqlQuery(query) .schemaBaseLine(expectedSchema) .go();
This JIRA is opened to ask for enhance test framework to make it enforce column order as well.