Repository navigation
Spark: [3/N] Support sending referenced-by to all endpoints - #13979
singhpk234 wants to merge 11 commits into
Conversation
gaborkaszab
left a comment
There was a problem hiding this comment.
Thanks for the PR @singhpk234 !
I took a look for my own benefit, and left some observations and questions meanwhile. Let me know what you think!
|
|
||
| @Override | ||
| public Table loadTableViaView(TableIdentifier identifier, Map<String, Object> viewContext) { | ||
| if (delegate instanceof ContextAwareTableCatalog) { |
There was a problem hiding this comment.
delegate is a BaseSessionCatalog.AsCatalog that now implements ContextAwareTableCatalog. Is there a use-case or configuration where delegate doesn't implement the new interface?
I see the concept in this class is rather to have a new member of type ContextAwareTableCatalog that is converted from delegate and this new function could directly call that. Similarly as nsCatalog.
Would this also work here? Do I miss something?
97296ab to
bcec3f2
Compare
a34c0f2 to
fb6e824
Compare
20d30b3 to
737fc50
Compare
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
f368355 to
57e3e30
Compare
gaborkaszab
left a comment
There was a problem hiding this comment.
I went through the api/ and core/ part for now (haven't checked Spark). Left some questions and nits. I also found some of my previous comments so I'm not sure this was ready for review.
Anyway, some test coverage in TestRESTCatalog would be great!
|
Hi all - the Iceberg REST spec was merged 😃 This PR is now the next step in getting this referenced-by feature into the different Iceberg clients, right? Looking forward to get it merged & released |
57e3e30 to
a300631
Compare
684da4f to
acc960c
Compare
2479b08 to
be411cc
Compare
be411cc to
bce1ced
Compare
4693c3f to
e8b01f5
Compare
Resolve the chain of views a relation was reached through and pass it to the catalog as a LoadContext, so a REST catalog can forward it to the server. SparkSupportsLoadContext extends the loading contract with context-carrying overloads of loadTable and loadView, including the time-travel forms, and SparkCatalog and SparkSessionCatalog implement it. ResolveViews records the chain while resolving nested views, with UnResolvedRelationFromView carrying it through analysis. Cross-catalog view references fail rather than silently dropping the chain. Gated behind spark.sql.iceberg.referenced-by-enabled, off by default.
Generated-by: Codex
Generated-by: Codex
TestSparkCatalog only overrode loadTable(Identifier), so once the read path started resolving through loadRelation -> loadTable(Identifier, LoadContext), the double was no longer consulted and lookups fell through to the real catalog. Override the contextual variant to delegate to the existing one. The double ignores the context; TestReferencedByViewChain covers the referenced-by behaviour against real catalogs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Restore the Spark 4.1-style analyzer path for referenced-by propagation in Spark 4.2. ResolveViews now expands Iceberg views, carries the view chain through UnResolvedRelationFromView, and loads nested relations with an explicit LoadContext instead of using SQLConf-backed view metadata. Generated-by: Codex
Preserve existing cross-catalog view behavior by dropping catalog-relative referenced-by entries that cannot be represented for the target catalog. Bypass CachingCatalog for non-empty LoadContext loads so referenced-by reaches catalogs such as REST, and add regression coverage for cache-enabled Spark reads, time-travel views, and cross-catalog view references. Generated-by: Codex
Add a default-off Spark SQL flag for referenced-by view-chain propagation. When disabled, Spark keeps its native view resolution behavior, including cross-catalog views. When enabled, Iceberg uses the explicit analyzer path and rejects cross-catalog chains because LoadContext carries catalog-relative identifiers. Generated-by: Codex
Build the referenced-by view chain from the catalog and identifier Spark resolved when loading the view. Keep view metadata current catalog and namespace only for resolving unqualified references inside the view SQL. Generated-by: Codex
Keep the view chain on Spark's pre-execution table refresh by binding it to the catalog of relations resolved through a view, so a table read through a view is never reloaded as direct access. Convert view time travel with Spark's TimeTravelSpec so string and integer timestamps work and pinned snapshots are not refreshed. Leave V1 and delegating tables read through a view to Spark, and alias view-resolved tables so table-qualified columns resolve. Remove loadRelation overrides that duplicate BaseCatalog.
Move referenced-by view expansion out of ResolveViews into ResolveReferencedByViews, which does nothing when referenced-by is disabled. ResolveViews is back to its main behavior. With referenced-by enabled, BaseCatalog.loadRelation returns tables only, so Spark resolves tables itself and leaves Iceberg views unresolved for the new rule. This removes the hint-batch registration, which Spark's Hive session state ignores, and keeps a table read to a single load. Expanded views are wrapped in Spark's View node so cycle detection and cache invalidation keep working, and parse, streaming and not-found errors match Spark's. LoadContext gains equals and hashCode so cached plans over a view are reused by later queries. SparkSessionCatalog fails a load with a referenced-by chain when its Iceberg catalog cannot pass the context, instead of dropping it. Generated-by: Claude Code
…extual loads Fail referenced-by view expansion past spark.sql.view.maxNestedViewDepth with the same error Spark raises when referenced-by is disabled, so a view cycle no longer overflows the stack during analysis. CachingCatalog now sends contextual loads the same canonical identifier as cached loads, so a table read through a view and read directly reach the delegate under one name when the cache is case-insensitive. Drop two Spark tests covered by more specific ones. Generated-by: Claude Code
About the change
This provides a reference implementation for passing the view name that table is referenced in as part of which the loadTable call is being made.
Details on the spec change proposal and motivation here