COLDMANYU opened a new pull request, #14928:
URL: https://github.com/apache/gravitino/pull/14928

   ### What changes were proposed in this pull request?
   
   - `GravitinoPaimonCatalog#createSparkTable` returns a table loaded by 
Paimon's `SparkCatalog` as it is when it is not a `SparkTable`, instead of 
casting it and wrapping it in `SparkPaimonTable`.
   - New `SparkPaimonCatalogHiveBackendIT` (and 
`SparkPaimonCatalogHiveBackendIT35`) runs the common Spark connector tests on a 
Paimon catalog with the Hive backend, against the Hive metastore of the test 
Hive container. It adds one test that creates a partitioned CSV format table 
with a Paimon `SparkCatalog` on the same metastore, then reads it through 
Gravitino, with and without a partition filter, and drops it.
   - New unit test `TestGravitinoPaimonCatalogTableWrapping`.
   
   ### Why are the changes needed?
   
   Paimon's `SparkCatalog` returns a `SparkTable` only for Paimon file store 
tables. A format table (a CSV, JSON, ORC, Parquet or text table registered in 
the metastore, which the Hive backend supports) comes back as a different Spark 
table: a Spark file table such as `PartitionedCSVTable` in Paimon 1.2, or a 
`PaimonFormatTable` in newer Paimon versions. `GravitinoPaimonCatalog` cast 
every table to `SparkTable`, so loading a format table failed:
   
   ```
   java.lang.ClassCastException: class 
org.apache.spark.sql.execution.PartitionedCSVTable cannot be cast to class 
org.apache.paimon.spark.SparkTable
       at 
org.apache.gravitino.spark.connector.paimon.GravitinoPaimonCatalog.createSparkTable(GravitinoPaimonCatalog.java:67)
       at 
org.apache.gravitino.spark.connector.catalog.BaseCatalog.loadTable(BaseCatalog.java:338)
   ```
   
   Such a table already has its schema and partitions resolved by Paimon and 
reads and writes through its own code path, so the connector returns it 
unchanged.
   
   The Hive backend had no Spark connector IT. #5858 started one but was closed 
without being merged; this PR continues it.
   
   Fixes #4733
   
   ### Does this PR introduce _any_ user-facing change?
   
   Format tables in a Paimon catalog can be read and written through the 
Gravitino Spark connector. They are returned as Paimon's own Spark table, so 
Gravitino-specific table handling does not apply to them. Paimon file store 
tables are unchanged.
   
   ### How was this patch tested?
   
   - Unit test: `TestGravitinoPaimonCatalogTableWrapping` checks that a 
`SparkTable` is still wrapped and that another table is returned as it is.
   - Without the fix, the unit test and `testReadExternalCsvFormatTable` fail 
with the `ClassCastException` above.
   - `SparkPaimonCatalogHiveBackendIT35`: 37 tests, 32 passed, 5 skipped 
(features the Paimon catalog does not support; the filesystem backend skips the 
same 5).
   - `SparkPaimonCatalogFilesystemBackendIT35` still passes.
   - Two common schema tests check the schema comment, which the Paimon catalog 
does not store yet (#5719). The Hive backend IT overrides them without the 
comment check, with a note to restore it once #5719 is fixed.
   


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

Reply via email to