cloud-fan opened a new pull request, #56027:
URL: https://github.com/apache/spark/pull/56027
### What changes were proposed in this pull request?
Follow-up to SPARK-55250. Restore the `namespaceExists` short-circuit in
`CreateNamespaceExec.run()` for the `IF NOT EXISTS` case only:
```scala
if (ifNotExists && catalog.namespaceExists(ns)) {
return Seq.empty
}
```
The unconditional `createNamespace` call path introduced by SPARK-55250 is
preserved for `CREATE NAMESPACE foo` (no `IF NOT EXISTS`), so the perf win from
that PR is kept for the common create-fresh path.
### Why are the changes needed?
SPARK-55250 changed `CREATE NAMESPACE IF NOT EXISTS foo` from "check
existence first, skip if present" to "always call `createNamespace`, catch
`NamespaceAlreadyExistsException`". For `SupportsNamespaces` implementations
that validate the request (properties, ownership, etc.) before checking
existence, this surfaces errors that the previous short-circuit avoided.
Concretely, a user with `IF NOT EXISTS` on an already-existing namespace can
now hit a `createNamespace`-side validation failure even though the user's
intent was a no-op.
### Does this PR introduce _any_ user-facing change?
Yes. `CREATE NAMESPACE IF NOT EXISTS foo` on a pre-existing namespace is
again a no-op without invoking `createNamespace`, matching the pre-SPARK-55250
behavior.
### How was this patch tested?
- New `CreateNamespaceExecSuite` with a stub `SupportsNamespaces` whose
`createNamespace` throws to assert the short-circuit; covers all four matrix
points (`ifNotExists` × `existing`).
- Existing
`org.apache.spark.sql.hive.execution.command.CreateNamespaceSuite` "hive client
calls" test still asserts exactly 1 RPC for each of the three `CREATE
NAMESPACE` shapes — the perf win from SPARK-55250 is preserved.
- Existing v1 / v2 `CreateNamespaceSuite` pass.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.7)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]