Aggarwal-Raghav commented on code in PR #6665:
URL: https://github.com/apache/hive/pull/6665#discussion_r3851006935
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -4737,6 +4737,40 @@ static boolean isRegex(String pattern, HiveConf conf) {
return false;
}
+ protected record ExcludeResult(String tableAlias, Set<ColumnInfo>
excludedColumns) {}
+
+ protected ExcludeResult processAllColRefAndExclude(ASTNode expr, RowResolver
inputRR)
+ throws SemanticException {
+ // Check if the query uses SELECT * EXCLUDE. If it does, grab the table
+ // alias (like t.*) and build a list of the columns the user wants to
exclude.
+ String starTabAlias = null;
+ ASTNode excludeNode = null;
+ Set<ColumnInfo> excludedColumns = new HashSet<>();
+
+ if (expr.getChildren() != null) {
+ for (Node childNode : expr.getChildren()) {
+ ASTNode child = (ASTNode) childNode;
+ switch (child.getType()) {
+ case HiveParser.TOK_TABNAME -> starTabAlias =
getUnescapedName(child).toLowerCase();
+ case HiveParser.TOK_TABCOLNAME -> excludeNode = child;
+ default ->
+ throw new SemanticException(
+ "Unexpected node type in TOK_ALLCOLREF: " + child.getType());
+ }
+ }
+ }
+
+ if (excludeNode != null) {
+ for (int e = 0; e < excludeNode.getChildCount(); e++) {
+ String excludeColName =
unescapeIdentifier(excludeNode.getChild(e).getText()).toLowerCase();
+ ColumnInfo colInfo = inputRR.get(starTabAlias, excludeColName);
+ if (colInfo != null) {
+ excludedColumns.add(colInfo);
+ }
+ }
Review Comment:
ACK
--
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]