DRILL-5845: Columns returned by select with "ORDER BY" and "LIMIT" clauses are not in correct order.
This closes #1000 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/c4eaf4b8 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/c4eaf4b8 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/c4eaf4b8 Branch: refs/heads/master Commit: c4eaf4b8697a32a6786e9c5b5a6023327ec461ae Parents: f1d1945 Author: Vitalii Diravka <[email protected]> Authored: Mon Oct 9 11:27:58 2017 +0000 Committer: Parth Chandra <[email protected]> Committed: Fri Oct 20 16:52:34 2017 -0700 ---------------------------------------------------------------------- .../exec/physical/impl/TopN/TopNBatch.java | 1 - .../java/org/apache/drill/TestStarQueries.java | 21 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/c4eaf4b8/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java index e77c186..950e1fe 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java @@ -139,7 +139,6 @@ public class TopNBatch extends AbstractRecordBatch<TopN> { v.clear(); } } - c = VectorContainer.canonicalize(c); for (VectorWrapper<?> w : c) { @SuppressWarnings("resource") ValueVector v = container.addOrGet(w.getField()); http://git-wip-us.apache.org/repos/asf/drill/blob/c4eaf4b8/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java index 819704c..bdb080c 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -24,6 +24,8 @@ import org.apache.drill.common.exceptions.UserException; import org.apache.drill.common.types.TypeProtos; import org.apache.drill.common.util.FileUtils; import org.apache.drill.common.util.TestTools; +import org.apache.drill.exec.record.BatchSchema; +import org.apache.drill.test.rowSet.SchemaBuilder; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -512,4 +514,21 @@ public class TestStarQueries extends BaseTestQuery{ query2, expectedRecordCount, actualRecordCount), expectedRecordCount, actualRecordCount); } + @Test // DRILL-5845 + public void testSchemaForStarOrderByLimit() throws Exception { + final String query = "select * from cp.`tpch/nation.parquet` order by n_name limit 1"; + final BatchSchema expectedSchema = new SchemaBuilder() + .add("n_nationkey", TypeProtos.MinorType.INT) + .add("n_name",TypeProtos.MinorType.VARCHAR) + .add("n_regionkey", TypeProtos.MinorType.INT) + .add("n_comment", TypeProtos.MinorType.VARCHAR) + .build(); + + testBuilder() + .sqlQuery(query) + .schemaBaseLine(expectedSchema) + .build() + .run(); + } + }
