Skip to content

Commit

Permalink
PHOENIX-4322 DESC primary key column with variable length does not wo…
Browse files Browse the repository at this point in the history
…rk in SkipScanFilter
  • Loading branch information
maryannxue committed Oct 30, 2017
1 parent 0c38f49 commit b0220fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ public void inDescCompositePK2() throws Exception {
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 INTEGER NOT NULL, code VARCHAR NOT NULL constraint pk primary key (oid DESC, code DESC))";
Object[][] insertedRows = new Object[][]{{1, "o1"}, {2, "o2"}, {3, "o3"}};
runQueryTest(ddl, upsert("oid", "code"), insertedRows, new Object[][]{{2, "o2"}, {1, "o1"}},
new WhereCondition("(oid, code)", "IN", "((1, 'o1'), (2, 'o2'))"), table);
}

@Test
public void likeDescCompositePK1() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,11 @@ public static int setKey(RowKeySchema schema, List<List<KeyRange>> slots, int[]
anyInclusiveUpperRangeKey |= !range.isSingleKey() && inclusiveUpper;
// A null or empty byte array is always represented as a zero byte
byte sepByte = SchemaUtil.getSeparatorByte(schema.rowKeyOrderOptimizable(), bytes.length == 0, field);

if ( !isFixedWidth && ( sepByte == QueryConstants.DESC_SEPARATOR_BYTE
// The result of an RVC evaluation can come with a trailing separator already, so we
// should avoid adding another one.
if ( !isFixedWidth
&& ( bytes.length == 0 || key[offset - 1] != sepByte )
&& ( sepByte == QueryConstants.DESC_SEPARATOR_BYTE
|| ( !exclusiveUpper
&& (fieldIndex < schema.getMaxFields() || inclusiveUpper || exclusiveLower) ) ) ) {
key[offset++] = sepByte;
Expand Down

0 comments on commit b0220fa

Please sign in to comment.