[#11287] feat(spark-connector): Add view support#11288
Open
diqiu50 wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds read-only Gravitino view support to the Spark Hive V2 connector by falling back from table resolution to view resolution and introducing a Spark-side Table implementation to execute view SQL.
Changes:
- Extend Spark connector table resolution (
loadTable,tableExists) to recognize Gravitino views. - Add
SparkHiveViewto execute view SQL (Spark dialect preferred; Hive dialect fallback) and expose results via a V2 scan. - Update Hive view catalog operations to accept Spark dialect; add/extend unit + integration coverage for view behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/catalog/BaseCatalog.java | Adds view fallback in loadTable and view-aware existence checks; introduces loadViewAsTable/createSparkView hooks. |
| spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/SparkHiveView.java | New Spark V2 Table wrapper that executes stored view SQL and returns rows via a single partition scan. |
| spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/hive/GravitinoHiveCatalog.java | Overrides createSparkView to wrap Hive views with SparkHiveView. |
| catalogs/catalog-hive/src/main/java/org/apache/gravitino/catalog/hive/HiveViewCatalogOperations.java | Allows Spark dialect when validating/loading/serializing HMS views. |
| spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/hive/SparkHiveCatalogIT.java | Adds integration tests for selecting from views, tableExists behavior, SHOW TABLES behavior, and CREATE VIEW limitation. |
| catalogs/catalog-hive/src/test/java/org/apache/gravitino/catalog/hive/TestHiveCatalogOperations.java | Updates unit test to assert Spark dialect is accepted for view creation. |
….version property for Spark views
Code Coverage Report
Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add read-only view support to the Gravitino Spark Hive connector:
HiveViewCatalogOperations: accept Spark dialect in view creation and loading.BaseCatalog: fall through to view lookup inloadTablewhen identifier isnot a table; check view existence in
tableExists.SparkHiveView: new V2 Table that executes view SQL via SparkSession on thedriver and returns rows as a single in-memory partition.
GravitinoHiveCatalog: overridecreateSparkViewto returnSparkHiveView.Why are the changes needed?
Fix: #11287
Does this PR introduce any user-facing change?
Yes — users can now SELECT from Gravitino views via Spark SQL on Hive catalogs.
Note: CREATE VIEW via Spark SQL is not supported due to a Spark V2 named catalog
limitation; views must be created through the Gravitino API.
How was this patch tested?
testCreateViewAcceptsSparkDialectinTestHiveCatalogOperationsSparkHiveCatalogIT:testSelectHiveView,testTableExistsForView,testShowTablesExcludesViews,testCreateViewViaSql