kasakrisz commented on code in PR #6439:
URL: https://github.com/apache/hive/pull/6439#discussion_r3109116558
##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveUtils.java:
##########
@@ -354,8 +354,20 @@ public Object process(Node nd, Stack<Node> stack,
NodeProcessorCtx procCtx, Obje
throws SemanticException {
UnparseTranslator unparseTranslator =
((QuotedIdExpressionContext)procCtx).getUnparseTranslator();
ASTNode identifier = (ASTNode) nd;
- String id = identifier.getText();
- if (FunctionRegistry.getFunctionInfo(id) != null){
+ /*
+ * Quote identifiers during unparse.
+ *
+ * Only skip quoting for function names.
+ * Always quote column names, even if they match function names.
+ * For example, use `alias`.`date` instead of `alias`.date.
+ */
+ ASTNode parent = (ASTNode) identifier.getParent();
+ if (parent != null
+ && (parent.getType() == HiveParser.TOK_FUNCTION
+ || parent.getType() == HiveParser.TOK_FUNCTIONDI
+ || parent.getType() == HiveParser.TOK_FUNCTIONSTAR)
+ && parent.getChildCount() > 0
+ && parent.getChild(0) == identifier) {
Review Comment:
I think this is a good solution.
The alternative would be to
* remove the `IdentifierProcessor`
* add separate processors for `TOK_TABNAME`, `TOK_TABLE_OR_COL`,
`TOK_FUNCTION` etc.
The risk of this alternative is that we might miss an AST node.
So let's keep yours.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]