kishoreg commented on a change in pull request #6066:
URL: https://github.com/apache/incubator-pinot/pull/6066#discussion_r533828645
##########
File path:
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -984,32 +984,57 @@ private void fixColumnName(String rawTableName,
TransformExpressionTree expressi
private void fixColumnName(String rawTableName, Expression expression,
@Nullable Map<String, String> columnNameMap) {
ExpressionType expressionType = expression.getType();
if (expressionType == ExpressionType.IDENTIFIER) {
- Identifier identifier = expression.getIdentifier();
- identifier.setName(getActualColumnName(rawTableName,
identifier.getName(), columnNameMap));
+ if (!isStarIdentifier(expression)) {
+ Identifier identifier = expression.getIdentifier();
+ identifier.setName(getActualColumnName(rawTableName,
identifier.getName(), columnNameMap));
+ }
} else if (expressionType == ExpressionType.FUNCTION) {
- for (Expression operand : expression.getFunctionCall().getOperands()) {
- fixColumnName(rawTableName, operand, columnNameMap);
+ String operator = expression.getFunctionCall().getOperator();
+ List<Expression> expressions =
expression.getFunctionCall().getOperands();
+ if ("AS".equals(operator)) {
+ fixColumnName(rawTableName, expressions.get(0), columnNameMap);
+ } else if (!isCountStarFromExpression(expression)) {
+ for (Expression operand : expression.getFunctionCall().getOperands()) {
+ fixColumnName(rawTableName, operand, columnNameMap);
+ }
}
}
}
- private String getActualColumnName(String rawTableName, String columnName,
- @Nullable Map<String, String> columnNameMap) {
+ private boolean isCountStarFromExpression(Expression expression) {
+ String operator = expression.getFunctionCall().getOperator();
+ List<Expression> expressions = expression.getFunctionCall().getOperands();
+ return "COUNT".equals(operator) && expressions.size() == 1 &&
isStarIdentifier(expressions.get(0));
+ }
+
+ private boolean isStarIdentifier(Expression expression) {
+ return "*".equals(expression.getIdentifier().getName());
+ }
+
+ private String getActualColumnName(String rawTableName, String columnName,
Map<String, String> columnNameMap) {
Review comment:
doing validation in this method is not a good idea - the name of the
method and what it does should match. Its also confusing to do validation as
part of this method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]