spark-test commented on code in PR #60722:
URL: https://github.com/apache/spark/pull/60722#discussion_r4636153325


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RelationResolution.scala:
##########
@@ -112,6 +114,85 @@ class RelationResolution(
     Seq(nameParts.last)
   }
 
+  /**
+   * Resolves DDL and miscellaneous command targets to [[ResolvedTable]], 
[[ResolvedTempView]] or
+   * [[ResolvedPersistentView]], without expanding view definitions. Temporary 
views are looked up
+   * before persistent catalog objects.
+   *
+   * When `viewOnly=true`, non-session catalogs that do not implement 
[[ViewCatalog]] are
+   * rejected with MISSING_CATALOG_ABILITY.VIEWS. [[UnresolvedView]] callers 
reject non-view results
+   * downstream via `expectViewNotTableError`.
+   *
+   * Persistent catalog lookup order:
+   *   1. If the catalog is a [[RelationCatalog]], 
[[RelationCatalog.loadRelation]] is called
+   *      once. A returned [[View]] is interpreted as a view; a [[Table]] is a 
table.
+   *      [[NoSuchTableException]] means neither exists.
+   *   2. Otherwise, [[TableCatalog.loadTable]] is tried (when implemented), 
then
+   *      [[ViewCatalog.loadView]] as the fallback view-resolution path (when 
implemented).

Review Comment:
   **Nit (P3):** With this heading the numbered steps describe every persistent 
catalog, including `spark_catalog`, where the base branch's Scaladoc limited 
them to non-session catalogs. For the built-in session catalog they do not 
match the code. `V2SessionCatalog` is neither a `RelationCatalog` nor a 
`ViewCatalog`, so step 1 and the `loadView` fallback never apply to it. Its 
views resolve only because the method body turns a view-like `V1Table` from 
`loadTable` into a `ResolvedPersistentView` over `V1View` (lines 166-172), 
which the steps do not mention. Someone reusing the now-public method could 
read step 2 as saying that `loadTable` only ever yields tables. This affects 
documentation only; the lookup's behavior is unchanged. Adding the 
session-catalog rule to step 2 keeps the broader heading accurate:
   
   ```suggestion
      * Persistent catalog lookup order:
      *   1. If the catalog is a [[RelationCatalog]], 
[[RelationCatalog.loadRelation]] is called
      *      once. A returned [[View]] is interpreted as a view; a [[Table]] is 
a table.
      *      [[NoSuchTableException]] means neither exists.
      *   2. Otherwise, [[TableCatalog.loadTable]] is tried (when implemented), 
then
      *      [[ViewCatalog.loadView]] as the fallback view-resolution path 
(when implemented).
      *      For the session catalog, a view-like [[V1Table]] from `loadTable` 
resolves to a
      *      [[ResolvedPersistentView]] over a [[V1View]].
   ```
   
   **Verification:**
   - **Inspection:** Reading the lookupTableOrView Scaladoc against the method 
body shows that its persistent-catalog steps cover the session catalog's 
view-like V1Table branch. Each documented step matches the code for the 
built-in session catalog, a RelationCatalog, a TableCatalog, and a catalog that 
implements only ViewCatalog.



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