You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/01/26 15:33:12 UTC
[GitHub] [hive] kasakrisz commented on a change in pull request #1892: HIVE-24664: Support column aliases in Values clause
kasakrisz commented on a change in pull request #1892:
URL: https://github.com/apache/hive/pull/1892#discussion_r564604533
##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -151,11 +182,46 @@ expressionsNotInParenthesis[boolean isStruct, boolean forceStruct]
-> {$more.tree}
;
-expressionPart[CommonTree t, boolean isStruct]
+expressionPart[CommonTree firstExprTree, boolean isStruct]
:
(COMMA expression)+
- -> {isStruct}? ^(TOK_FUNCTION Identifier["struct"] {$t} expression+)
- -> {$t} expression+
+ -> {isStruct}? ^(TOK_FUNCTION Identifier["struct"] {$firstExprTree} expression+)
+ -> {$firstExprTree} expression+
+ ;
+
+// Parses comma separated list of expressions with optionally specified aliases and store the aliases for further usage.
+// <expression> [<alias>] [, <expression> [<alias>]]
+firstExpressionsWithAlias
+@init { initAliases(); }
+ :
+ first=expression colAlias=identifier? (COMMA expressionWithAlias)*
+ -> {colAlias != null}? ^(TOK_FUNCTION Identifier["named_struct"] { adaptor.create(Identifier, addAlias($colAlias.tree.getText())) } {$first.tree} expressionWithAlias*)
Review comment:
I changed the rule `valuesTableConstructor` by adding an alternative: if there are no aliases defined for any of the values let's parse the values clause in the lagacy way which transforms to array of structs.
This seems to revert lots of the q.out files.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org