Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 dfc1af7d9 -> 1928ba03c
PHOENIX-2067 Sort order incorrect for variable length DESC columns Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1928ba03 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1928ba03 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1928ba03 Branch: refs/heads/4.x-HBase-0.98 Commit: 1928ba03ccdf4dd3a9365159b7b6d2ec2f001af2 Parents: dfc1af7 Author: James Taylor <[email protected]> Authored: Tue Jul 14 13:40:58 2015 -0700 Committer: James Taylor <[email protected]> Committed: Tue Jul 14 13:41:45 2015 -0700 ---------------------------------------------------------------------- .../org/apache/phoenix/util/UpgradeUtil.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/1928ba03/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java index 81c9085..c7baf43 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java @@ -80,12 +80,11 @@ import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.SaltingUtil; import org.apache.phoenix.schema.SortOrder; import org.apache.phoenix.schema.types.PBoolean; +import org.apache.phoenix.schema.types.PDataType; import org.apache.phoenix.schema.types.PDecimal; -import org.apache.phoenix.schema.types.PDecimalArray; import org.apache.phoenix.schema.types.PInteger; import org.apache.phoenix.schema.types.PLong; import org.apache.phoenix.schema.types.PVarchar; -import org.apache.phoenix.schema.types.PVarcharArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -878,6 +877,20 @@ public class UpgradeUtil { } return otherTables; } + + // Return all types that are not fixed width that may need upgrading due to PHOENIX-2067 + // We exclude VARBINARY as we no longer support DESC for it. + private static String getAffectedDataTypes() { + StringBuilder buf = new StringBuilder("(" + PVarchar.INSTANCE.getSqlType() + "," + PDecimal.INSTANCE.getSqlType() + ","); + for (PDataType type : PDataType.values()) { + if (type.isArrayType()) { + buf.append(type.getSqlType()); + buf.append(','); + } + } + buf.setCharAt(buf.length()-1, ')'); + return buf.toString(); + } /** * Identify the tables that need to be upgraded due to PHOENIX-2067 */ @@ -890,7 +903,7 @@ public class UpgradeUtil { "WHERE COLUMN_NAME IS NOT NULL\n" + "AND COLUMN_FAMILY IS NULL\n" + "AND SORT_ORDER = " + SortOrder.DESC.getSystemValue() + "\n" + - "AND DATA_TYPE IN (" + PVarchar.INSTANCE.getSqlType() + "," + PDecimal.INSTANCE.getSqlType() + "," + PVarcharArray.INSTANCE.getSqlType() + "," + PDecimalArray.INSTANCE.getSqlType() + ")\n" + + "AND DATA_TYPE IN " + getAffectedDataTypes() + "\n" + "GROUP BY TENANT_ID,TABLE_SCHEM,TABLE_NAME"); Set<String> physicalTables = Sets.newHashSetWithExpectedSize(1024); List<String> remainingTableNames = addPhysicalTables(conn, rs, PTableType.INDEX, physicalTables);
