Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/34#discussion_r23669302
--- 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 --
I think you can likely do this by adding a boolean to the ParseNodeFactory
constructor (or deriving your own) that determines if column, table, schema
references are case sensitive. You'll use this option/subclass for your
SQLParser when you parse the expressionStr. Just specialize the following
methods:
public ColumnParseNode column(TableName tableName, String name, String
alias) {
return new ColumnParseNode(tableName,name,alias);
}
public TableName table(String schemaName, String tableName) {
return TableName.createNormalized(schemaName,tableName);
}
---
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 [email protected] or file a JIRA ticket
with INFRA.
---