dtenedor commented on code in PR #40710:
URL: https://github.com/apache/spark/pull/40710#discussion_r1161013565


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveDefaultColumns.scala:
##########
@@ -91,6 +90,25 @@ case class ResolveDefaultColumns(catalog: SessionCatalog) 
extends Rule[LogicalPl
     }
   }
 
+  /**
+   * Checks if a logical plan is an INSERT INTO command where the inserted 
data comes from a SELECT
+   * list, with possible other unary operators like sorting and/or alias(es) 
in between.
+   */
+  private def insertsFromProject(i: InsertIntoStatement): Option[Project] = {
+    var node = i.query
+    def matches(node: LogicalPlan): Boolean = node match {
+      case _: GlobalLimit | _: LocalLimit | _: Offset | _: SubqueryAlias | _: 
Sort => true

Review Comment:
   As I understand it, the intention is to allow and resolve `default` 
references in the top-most `Project`, but not such references within any table 
subqueries. For example, this should not work:
   
   ```
   insert into t2 (i, s) select i, s from (
     select default as i, default as s from t1 order by i limit 1)
   ```



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to