veghlaci05 commented on code in PR #3891:
URL: https://github.com/apache/hive/pull/3891#discussion_r1082601830
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java:
##########
@@ -101,17 +104,25 @@ public ASTNode getExpressionSource(ASTNode node) {
}
public void put(String tab_alias, String col_alias, ColumnInfo colInfo) {
+ if (!putInternal(tab_alias, col_alias, colInfo)) {
+ return;
+ }
+ if (col_alias != null) {
+ colInfo.setAlias(col_alias.toLowerCase());
+ }
+ }
+
+ public boolean putInternal(String tab_alias, String col_alias, ColumnInfo
colInfo) {
Review Comment:
`putInternal` could be private, it's only used inside `RowResolver`
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java:
##########
@@ -101,17 +104,25 @@ public ASTNode getExpressionSource(ASTNode node) {
}
public void put(String tab_alias, String col_alias, ColumnInfo colInfo) {
+ if (!putInternal(tab_alias, col_alias, colInfo)) {
+ return;
+ }
+ if (col_alias != null) {
+ colInfo.setAlias(col_alias.toLowerCase());
+ }
Review Comment:
why not merge the two ifs?
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java:
##########
@@ -481,11 +492,16 @@ public static RowResolver getCombinedRR(RowResolver
leftRR,
public RowResolver duplicate() {
RowResolver resolver = new RowResolver();
resolver.rowSchema = new RowSchema(rowSchema);
- resolver.rslvMap.putAll(rslvMap);
+ for (Map.Entry<String, Map<String, ColumnInfo>> entry :
rslvMap.entrySet()) {
+ resolver.rslvMap.put(entry.getKey(), new
LinkedHashMap<>(entry.getValue()));
+ }
resolver.invRslvMap.putAll(invRslvMap);
resolver.altInvRslvMap.putAll(altInvRslvMap);
resolver.expressionMap.putAll(expressionMap);
resolver.isExprResolver = isExprResolver;
+ for (Map.Entry<String, Map<String, String>> entry :
ambiguousColumns.entrySet()) {
+ resolver.ambiguousColumns.put(entry.getKey(), new
LinkedHashMap<>(entry.getValue()));
+ }
resolver.ambiguousColumns.putAll(ambiguousColumns);
Review Comment:
Now you are putting the items twice, is this intended?
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java:
##########
@@ -81,7 +81,10 @@ public RowResolver() {
public void putExpression(ASTNode node, ColumnInfo colInfo) {
String treeAsString = node.toStringTree();
expressionMap.put(treeAsString, node);
- put("", treeAsString, colInfo);
+ if (!putInternal("", treeAsString, colInfo)) {
+ return;
+ }
+ colInfo.setAlias(treeAsString);
Review Comment:
Why not invert the criteria and move colInfo.setAlias(treeAsString); inside
the if. I think that would increase code radability.
--
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]