Repository navigation
Conversation
… catalogs on session open A new Spark session is created via `newSession()`, so it starts from the SparkContext configs, i.e. the ones of the session which launched the engine. The session initialization SQLs and `use:catalog`/`use:database` ran before the session configs were applied, so catalog plugins touched by them (e.g. `USE iceberg`) were initialized with stale `spark.sql.catalog.<name>.*` configs, such as credentials of the first connection, and never re-read them. - Apply session configs to the new session before the initialization SQLs. - Apply session configs before switching catalog/database in `SparkSessionImpl.open`, and switch with the session set as active, since `CatalogManager` reads configs via `SQLConf.get`.
|
Thanks @capacman for tracking this down, especially the detail that I tested
The first case confirms that init SQL can now see the client’s setting. The second shows why it makes sense to keep applying the client config in Both tests in Overall LGTM. Three non-blocking nits:
|
- Use USE_DATABASE instead of the literal key in SparkSessionImpl.open. - Close the opened session and check TStatusCode in SessionConfBeforeCatalogInitSuite. - Extract KyuubiSparkUtil.withActiveSession and reuse it in SparkOperation.withLocalProperties.
|
Thanks @wangzhigang1999 for the review and the ABBA verification. All three nits are addressed in a6e9f4e:
|
Why are the changes needed?
Closes #7874.
A Kyuubi session's Spark session is created via
newSession(), so it starts with the configs of the connection that launched the engine. Catalog plugins readspark.sql.catalog.<name>.*only once, ininitialize. On session open, the initialize SQLs (kyuubi.engine.session.initialize.sql) anduse:catalog/use:databaseran before the session configs were applied. So a catalog touched by them, e.g. byUSE iceberg, got the stale configs (such as the first connection's credentials) and ignored the ones the client passed.SparkSQLSessionManager.newSparkSessionnow applies the session configs before it runs the initialize SQLs.SparkSessionImpl.opennow applies the session configs before switching catalog/database. It also makes the session active while switching, becauseCatalogManagerreads configs viaSQLConf.get.setModifiableConfigmoves toKyuubiSparkUtilso both places can call it.How was this patch tested?
Added
SessionConfBeforeCatalogInitSuite. It registers a catalog plugin that records the config it is initialized with, and checks that a session's own value wins over the engine-launch value, both through the initialize SQL and throughuse:catalog.Was this patch assisted by generative AI tooling?
Assisted-by: Claude:claude-opus-5-5
🤖 Generated with Claude Code