Jinfeng Ni created DRILL-5754:
---------------------------------
Summary: Test framework does not enforce column orders
Key: DRILL-5754
URL: https://issues.apache.org/jira/browse/DRILL-5754
Project: Apache Drill
Issue Type: Bug
Reporter: Jinfeng Ni
Drill has provided a test framework to submit SQL statements and verify the
query results against expected results. For instance
{code}
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();
{code}
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.
{code}
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();
{code}
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.
{code}
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();
{code}
This JIRA is opened to ask for enhance test framework to make it enforce column
order as well.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)