cloud-fan commented on code in PR #43843:
URL: https://github.com/apache/spark/pull/43843#discussion_r1400568556


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala:
##########
@@ -444,6 +448,145 @@ case class UnresolvedStar(target: Option[Seq[String]]) 
extends Star with Unevalu
   override def toString: String = target.map(_.mkString("", ".", 
".")).getOrElse("") + "*"
 }
 
+/**
+ * Represents some of the input attributes to a given relational operator, for 
example in
+ * "SELECT * EXCEPT(a) FROM ...".
+ *
+ * @param target an optional name that should be the target of the expansion. 
If omitted all
+ *              targets' columns are produced. This can only be a table name. 
This
+ *              is a list of identifiers that is the path of the expansion.
+ *
+ * @param excepts a list of names that should be excluded from the expansion.
+ *
+ */
+case class UnresolvedStarExcept(target: Option[Seq[String]], excepts: 
Seq[Seq[String]])
+  extends UnresolvedStarBase(target) {
+
+  /**
+   * We expand the * EXCEPT by the following three steps:
+   * 1. use the original .expand() to get top-level column list or struct 
expansion
+   * 2. resolve excepts (with respect to the Seq[NamedExpression] returned 
from (1))
+   * 3. filter the expanded columns with the resolved except list. recursively 
apply filtering in
+   *    case of nested columns in the except list (in order to rewrite structs)
+   */
+  override def expand(input: LogicalPlan, resolver: Resolver): 
Seq[NamedExpression] = {
+    // Use the UnresolvedStarBase expand method to get a seq of 
NamedExpressions corresponding to
+    // the star expansion. This will yield a list of top-level columns from 
the logical plan's
+    // output, or in the case of struct expansion (e.g. target=`x` for SELECT 
x.*) it will give
+    // a seq of NamedExpressions corresponding to struct fields.

Review Comment:
   ```suggestion
       // a seq of Alias corresponding to struct fields.
   ```



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