Github user JamesRTaylor commented on a diff in the pull request: https://github.com/apache/phoenix/pull/34#discussion_r23668722 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java --- @@ -69,31 +68,29 @@ public String getTableAlias() { return alias; } - public String getColumnDisplayName(ColumnRef ref) { + public String getColumnDisplayName(ColumnRef ref, boolean cfCaseSensitive, boolean cqCaseSensitive) { + String cf = null; + String cq = null; PColumn column = ref.getColumn(); + String name = column.getName().getString(); + boolean isIndex = table.getType() == PTableType.INDEX; if (table.getType() == PTableType.JOIN || table.getType() == PTableType.SUBQUERY) { - return column.getName().getString(); + cq = column.getName().getString(); } - boolean isIndex = table.getType() == PTableType.INDEX; - if (SchemaUtil.isPKColumn(column)) { - String name = column.getName().getString(); - if (isIndex) { - return IndexUtil.getDataColumnName(name); - } - return name; + else if (SchemaUtil.isPKColumn(column)) { + cq = isIndex ? IndexUtil.getDataColumnName(name) : name; } - - if (isIndex) { - // Translate to the data table column name - String indexColumnName = column.getName().getString(); - String dataFamilyName = IndexUtil.getDataColumnFamilyName(indexColumnName); - String dataColumnName = IndexUtil.getDataColumnName(indexColumnName); + else { String defaultFamilyName = table.getDefaultFamilyName() == null ? QueryConstants.DEFAULT_COLUMN_FAMILY : table.getDefaultFamilyName().getString(); - return SchemaUtil.getColumnDisplayName(defaultFamilyName.equals(dataFamilyName) ? null : dataFamilyName, dataColumnName); + // Translate to the data table column name + String dataFamilyName = isIndex ? IndexUtil.getDataColumnFamilyName(name) : column.getFamilyName().getString() ; + cf = defaultFamilyName.equals(dataFamilyName) ? null : dataFamilyName; + cq = isIndex ? IndexUtil.getDataColumnName(name) : name; } - byte[] defaultFamily = table.getDefaultFamilyName() == null ? QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES : table.getDefaultFamilyName().getBytes(); - String displayName = SchemaUtil.getColumnDisplayName(Bytes.compareTo(defaultFamily, column.getFamilyName().getBytes()) == 0 ? null : column.getFamilyName().getBytes(), column.getName().getBytes()); - return displayName; + + cf = (cf!=null && cfCaseSensitive) ? "\"" + cf + "\"" : cf; + cq = cqCaseSensitive ? "\"" + cq + "\"" : cq; + return SchemaUtil.getColumnDisplayName(cf, cq); --- End diff -- Probably easier is to always treat column references in functional expressions as case sensitive. If they had double quotes originally, they'd have been left as-is, and if they didn't, they'd be upper-cased.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---