vladimirg-db commented on code in PR #49658:
URL: https://github.com/apache/spark/pull/49658#discussion_r1940753136


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/resolver/ExpressionResolver.scala:
##########
@@ -288,30 +473,148 @@ class ExpressionResolver(
 
   /**
    * [[Literal]] resolution doesn't require any specific resolution logic at 
this point.
+   */
+  private def resolveLiteral(literal: Literal): Expression = literal
+
+  /**
+   * The [[GetViewColumnByNameAndOrdinal]] is a special internal expression 
that is placed by the
+   * [[SessionCatalog]] in the top [[Project]] operator of the freshly 
reconstructed unresolved
+   * view plan. Since the view schema is fixed and persisted in the catalog, 
we have to extract
+   * the right attributes from the view plan regardless of the underlying 
table schema changes.
+   * [[GetViewColumnByNameAndOrdinal]] contains attribute name and it's 
ordinal to perform the
+   * necessary matching. If the matching was not successful, or the number of 
matched candidates
+   * differs from the recorded one, we throw an error.
+   *
+   * Example of the correct name matching:
+   *
+   * {{{
+   * CREATE TABLE underlying (col1 INT, col2 STRING);
+   * CREATE VIEW all_columns AS SELECT * FROM underlying;
+   *
+   * -- View plan for the SELECT below will contain a Project node on top with 
the following
+   * -- expressions:
+   * -- getviewcolumnbynameandordinal(`spark_catalog`.`default`.`all_columns`, 
col1, 0, 1)
+   * -- getviewcolumnbynameandordinal(`spark_catalog`.`default`.`all_columns`, 
col2, 0, 1)

Review Comment:
   That's how it's rendered in Spark logical plan.



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