lisancao opened a new pull request, #59416:
URL: https://github.com/apache/spark/pull/59416

   ### What changes were proposed in this pull request?
   
   When a metric view is read, its source is now resolved under the metric 
view's analysis context, the same way `ViewResolution` resolves a view's child: 
in the catalog and namespace it was created in, with its captured SQL configs 
and the nested view depth limit. `ViewResolution` gets a `resolveMetricView` 
next to `resolve`, sharing the same code, and `ResolveRelations.resolveViews` 
calls it for a `MetricViewPlaceholder`.
   
   ### Why are the changes needed?
   
   The creation namespace is stored but wasn't used, so an unqualified source 
resolved in the querying session's current namespace. After `USE other`, a 
metric view over `t` read `other.t`, and a temporary view named `t` replaced 
the source. Regular views don't do this.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Unqualified names in a metric view's source (asset, SQL source, filter 
subqueries) resolve in the namespace the metric view was created in, and 
temporary views are not used, matching regular views. Affects 4.2.0.
   
   Functions in dimension and measure expressions still resolve in the querying 
session; those expressions are spliced into the query plan, so that needs a 
separate change.
   
   ### How was this patch tested?
   
   New tests in `MetricViewSuite` (session catalog and Hive) and 
`MetricViewV2CatalogSuite`: a table with the same name in another namespace, a 
namespace without the table, another catalog, and a temporary view with the 
source's name. They fail on master without this change. Existing analyzer, view 
and metric view suites pass.
   
   This contribution is my original work, and I license it to the project under 
the project's open source license.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 5.5)


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