yihua opened a new pull request, #20248:
URL: https://github.com/apache/hudi/pull/20248

   ### Describe the issue this Pull Request addresses
   
   issue: #20235, follow-up to #20240
   
   #20240 fixed a qualified read failing on a session catalog that rejects the 
`default` database, a case no Spark SQL test could catch because the test 
session runs on an in-memory catalog where `default` always works. Any new code 
path that probes `default` would ship unnoticed again.
   
   ### Summary and Changelog
   
   Every Spark SQL suite extending `HoodieSparkSqlTestBase` now runs on a test 
external catalog, `StrictDefaultDatabaseCatalog`, that throws 
`StrictDefaultDatabaseException` for any table, partition or function operation 
on `default` while database-level calls still work so the session can start. 
`StrictCatalogSharedState` installs it by overriding 
`SharedState.externalCatalog`; the test session is built reflectively because 
the `SparkSession` constructor that takes a `SharedState` is class-private (on 
Spark 4 it lives on `org.apache.spark.sql.classic.SparkSession` with a 
different arity, and both paths are exercised). The base creates a fixed 
non-default test database at the warehouse root and switches to it, so 
unqualified names and managed-table paths behave as before. Suites that 
hard-coded `default` in expected identifiers, SHOW output, 
`hoodie.database.name` dumps or new sessions now use the test database.
   
   `TestStrictCatalogRead` writes a table through the datasource with no 
recorded database name, registers it under the test database, and reads it with 
a qualified SELECT from a session whose current database is `default`, for a 
plain table and a bucket-indexed one. With the pre-#20240 `HoodieFileIndex` the 
plain read fails with the strict exception from 
`HoodieFileIndex.getConfigProperties`; with it, all cases pass.
   
   Verified locally: 20 suites on Spark 3.5 and the other 95 suites extending 
the base (621 cases), `TestStrictCatalogRead` and `TestCreateTable` on Spark 
4.0, and `TestStrictCatalogRead` on Spark 4.1 and 4.2; all Spark 4 modules 
compile.
   
   ### Impact
   
   Test infrastructure only. No production code changes.
   
   ### Risk Level
   
   low. A suite that still assumes `default` fails loudly in CI with the strict 
exception rather than passing silently.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


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