[
https://issues.apache.org/jira/browse/PHOENIX-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14295555#comment-14295555
]
ASF GitHub Bot commented on PHOENIX-514:
----------------------------------------
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.
> Support functional indexes
> --------------------------
>
> Key: PHOENIX-514
> URL: https://issues.apache.org/jira/browse/PHOENIX-514
> Project: Phoenix
> Issue Type: Task
> Reporter: James Taylor
> Assignee: Thomas D'Silva
> Labels: enhancement
>
> Instead of only defining the set of columns from the data table that make up
> an index, you should be able to use expressions. For example:
> CREATE INDEX upper_last_name_idx ON person (UPPER(last_name))
> Then in queries that use UPPER(last_name), we can replace them with column
> references to the index table.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)