Source:
<code>public ExpressionIndexParseNodeRewriter(PTable index, PhoenixConnection connection) throws SQLException { indexedParseNodeToColumnParseNodeMap = Maps.newHashMapWithExpectedSize(index.getColumns().size()); NamedTableNode tableNode = NamedTableNode.create(null, TableName.create(index.getParentSchemaName().getString(), index.getParentTableName().getString()), Collections.<ColumnDef> emptyList()); ColumnResolver dataResolver = FromCompiler.getResolver(tableNode, connection); StatementContext context = new StatementContext(new PhoenixStatement(connection), dataResolver); IndexStatementRewriter rewriter = new IndexStatementRewriter(dataResolver, null); ExpressionCompiler expressionCompiler = new ExpressionCompiler(context); for (PColumn column : index.getPKColumns()) { if (column.getExpressionStr()==null) { continue; } ParseNode expressionParseNode = SQLParser.parseCondition(column.getExpressionStr()); <START> if (expressionParseNode instanceof ColumnParseNode) { <END> continue; } Expression dataExpression = expressionParseNode.accept(expressionCompiler); PDataType expressionDataType = dataExpression.getDataType(); ParseNode indexedParseNode = expressionParseNode.accept(rewriter); PDataType indexColType = IndexUtil.getIndexColumnDataType(dataExpression.isNullable(), expressionDataType); ParseNode columnParseNode = new ColumnParseNode(null, column.getName().getString(), null, true); if ( indexColType != expressionDataType) { columnParseNode = NODE_FACTORY.cast(columnParseNode, expressionDataType, null, null); } indexedParseNodeToColumnParseNodeMap.put(indexedParseNode, columnParseNode); } }</code><technical_language>Remove if needed</technical_language>

Target:
public ExpressionIndexParseNodeRewriter(PTable index, PhoenixConnection connection) throws SQLException { indexedParseNodeToColumnParseNodeMap = Maps.newHashMapWithExpectedSize(index.getColumns().size()); NamedTableNode tableNode = NamedTableNode.create(null, TableName.create(index.getParentSchemaName().getString(), index.getParentTableName().getString()), Collections.<ColumnDef> emptyList()); ColumnResolver dataResolver = FromCompiler.getResolver(tableNode, connection); StatementContext context = new StatementContext(new PhoenixStatement(connection), dataResolver); IndexStatementRewriter rewriter = new IndexStatementRewriter(dataResolver, null); ExpressionCompiler expressionCompiler = new ExpressionCompiler(context); ColumnParseNodeVisitor columnParseNodeVisitor = new ColumnParseNodeVisitor(); int indexPosOffset = (index.getBucketNum() == null ? 0 : 1) + (index.isMultiTenant() ? 1 : 0) + (index.getViewIndexId() == null ? 0 : 1); List<PColumn> pkColumns = index.getPKColumns(); for (int i=indexPosOffset; i<pkColumns.size(); ++i) { PColumn column = pkColumns.get(i); if (column.getExpressionStr()==null) { continue; } ParseNode expressionParseNode = SQLParser.parseCondition(column.getExpressionStr()); columnParseNodeVisitor.reset(); expressionParseNode.accept(columnParseNodeVisitor); String colName = column.getName().getString(); if (columnParseNodeVisitor.isParseNodeCaseSensitive()) { colName = "\"" + colName + "\""; } Expression dataExpression = expressionParseNode.accept(expressionCompiler); PDataType expressionDataType = dataExpression.getDataType(); ParseNode indexedParseNode = expressionParseNode.accept(rewriter); PDataType indexColType = IndexUtil.getIndexColumnDataType(dataExpression.isNullable(), expressionDataType); ParseNode columnParseNode = new ColumnParseNode(null, colName, null); if ( indexColType != expressionDataType) { columnParseNode = NODE_FACTORY.cast(columnParseNode, expressionDataType, null, null); } indexedParseNodeToColumnParseNodeMap.put(indexedParseNode, columnParseNode); } }