Github user JamesRTaylor commented on a diff in the pull request: https://github.com/apache/phoenix/pull/34#discussion_r23708841 --- 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 -- Actually, thinking about this a bit more, you'll want to force schema, table, and column names to be surrounded by double quotes when the expression.toString() is done. This will prevent any parse errors for any strange names and ensure case sensitivity which is what you want. The column.toString() is based off of the displayName passed into ColumnRef. The displayName is actually gotten from the TableRef which is created in the ColumnResolver. So... you'll need to add an option in the ColumnResolver (in FromCompiler) that indicates that you want column references surrounded by double quotes (i.e. case sensitive). This info can be passed through the TableRef constructor and applied in the getDisplayName() method.
--- 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. ---