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

   ### What changes were proposed in this pull request?
   
   This PR routes view commands through V2 execution when a custom 
`ViewCatalog` is installed as
   `spark_catalog`.
   
   The change:
   
   - makes `ResolveSessionCatalog` use V1 view commands only for session 
catalogs that do not
     implement `ViewCatalog`, while preserving V1 handling for delegated 
`V1View` instances;
   - routes native custom-catalog view creation, alteration, inspection, 
metric-view creation, and
     removal through the existing V2 commands;
   - extends `SHOW VIEWS` to combine native V2 views with delegated V1 views 
and local/global
     temporary views, including filtering, de-duplication, multi-part 
namespaces, and namespace
     error handling; and
   - adds coverage for native, delegated, and temporary views in a custom 
session `ViewCatalog`.
   
   ### Why are the changes needed?
   
   Spark currently identifies `spark_catalog` as the session catalog and 
rewrites its view commands
   to V1 commands even when the configured implementation supports 
`ViewCatalog`. This bypasses the
   custom catalog's view implementation and makes commands such as `CREATE 
VIEW`, `ALTER VIEW`,
   `DROP VIEW`, and `SHOW VIEWS` behave inconsistently.
   
   The dispatch needs to consider the catalog's view capability and the 
resolved view payload so
   native V2 views use the custom catalog while delegated V1 and temporary 
views retain their
   existing behavior.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. When `spark_catalog` is configured with a custom `ViewCatalog`, 
persistent view DDL and
   inspection commands now operate through that catalog. Delegated V1 views and 
temporary views
   remain accessible, including through `SHOW VIEWS`. Session catalogs without 
`ViewCatalog` keep
   their existing V1 behavior.
   
   ### How was this patch tested?
   
   Added tests to `DataSourceV2MetadataViewSuite` covering:
   
   - V2 view and metric-view commands when a `ViewCatalog` is installed as 
`spark_catalog`;
   - delegated V1 views alongside native V2 and temporary views;
   - `SHOW VIEWS` filtering, custom-only and multi-part namespaces, and 
persistent/global-temp name
     collisions; and
   - rejection of V1-only namespaces hidden by the custom catalog.
   
   No tests were run locally, per the repository instructions for this session. 
`git diff --check`
   passes.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Codex (GPT-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