PHOENIX-4322 DESC primary key column with variable length does not work in SkipScanFilter
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/92b57c78 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/92b57c78 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/92b57c78 Branch: refs/heads/4.x-HBase-0.98 Commit: 92b57c7893c91d90d78e30171e233043dbcb4583 Parents: 541d6ac Author: maryannxue <maryann....@gmail.com> Authored: Tue Dec 5 10:59:41 2017 -0800 Committer: maryannxue <maryann....@gmail.com> Committed: Tue Mar 13 17:16:42 2018 -0700 ---------------------------------------------------------------------- .../it/java/org/apache/phoenix/end2end/SortOrderIT.java | 11 ++++++++++- .../expression/RowValueConstructorExpression.java | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/92b57c78/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java index 655dbb1..3f749c1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java @@ -167,7 +167,16 @@ public class SortOrderIT extends ParallelStatsDisabledIT { runQueryTest(ddl, upsert("oid", "code"), insertedRows, new Object[][]{{"o2", 2}}, new WhereCondition("oid", "IN", "('o2')"), table); } - + + @Test + public void inDescCompositePK3() throws Exception { + String table = generateUniqueName(); + String ddl = "CREATE table " + table + " (oid VARCHAR NOT NULL, code VARCHAR NOT NULL constraint pk primary key (oid DESC, code DESC))"; + Object[][] insertedRows = new Object[][]{{"o1", "1"}, {"o2", "2"}, {"o3", "3"}}; + runQueryTest(ddl, upsert("oid", "code"), insertedRows, new Object[][]{{"o2", "2"}, {"o1", "1"}}, new WhereCondition("(oid, code)", "IN", "(('o2', '2'), ('o1', '1'))"), + table); + } + @Test public void likeDescCompositePK1() throws Exception { String table = generateUniqueName(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/92b57c78/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java index 15f6e3e..9bb7234 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java @@ -199,8 +199,8 @@ public class RowValueConstructorExpression extends BaseCompoundExpression { // as otherwise we need it to ensure sort order is correct for (int k = expressionCount -1 ; k >=0 && getChildren().get(k).getDataType() != null - && !getChildren().get(k).getDataType().isFixedWidth() - && outputBytes[outputSize-1] == QueryConstants.SEPARATOR_BYTE ; k--) { + && !getChildren().get(k).getDataType().isFixedWidth() + && outputBytes[outputSize-1] == SchemaUtil.getSeparatorByte(true, false, getChildren().get(k)) ; k--) { outputSize--; } ptr.set(outputBytes, 0, outputSize);