kokila-19 commented on code in PR #6439:
URL: https://github.com/apache/hive/pull/6439#discussion_r3109521846


##########
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:
   That’s great. I’ve refactored the code into a helper method to improve 
readability.



-- 
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]

Reply via email to