[SPARK-59118][SQL] Error when doAs is used and not supported - #58414
Open
holdenk wants to merge 5 commits into
Open
[SPARK-59118][SQL] Error when doAs is used and not supported#58414holdenk wants to merge 5 commits into
holdenk wants to merge 5 commits into
Conversation
…, docs Extract the guard into checkImpersonationIsEnforced so it can be tested without standing up the Thrift services, and use AuthTypes.NONE/NOSASL instead of matching the literal strings. The old message told users to unset hive.server2.enable.doAs, which does not help -- Hive's own default is true. Say "set it to false" instead, and note the escape hatch is a Spark conf (--conf), not a --hiveconf. Target 4.4.0 rather than 5.0.0: this backports to branch-4.x, matching the sibling allowSettingSystemProperties conf. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Refusing to start breaks deployments that have been accepted for years, so it lands in the next major rather than a minor. branch-4.x logs a warning for the same configuration; the migration note points at both. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Two claims in the error message were wrong. doAs is not ignored outright -- HiveSessionProxy runs every session call under UGI.doAs, so metastore calls are impersonated and only query execution and storage access are not. That also makes "just set doAs=false" a downgrade rather than a no-op, since it drops metastore impersonation too, so the message and docs now say so. And --hiveconf does reach a spark.* conf (ServerOptionsProcessor turns it into a system property), so the "not --hiveconf" advice was simply false; the real caveat is that a static conf has to be set before the session is created. Nothing proved init() called the guard -- deleting that line left every test green, which is the whole security value of the change. Tests now go through init(), cover every verifying AuthTypes value, and pin that an untouched Hive config (doAs=true, auth=NONE) still starts. Moved the guard to the companion object so the tests do not construct a HiveServer2, whose constructor flips HiveConf's process-wide loadHiveServer2Config, and so the escape hatch is a plain argument rather than a deep-stubbed SparkSession. The tests move to their own suite, since they are about server startup rather than SparkExecuteStatementOperation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
holdenk
marked this pull request as ready for review
August 31, 2026 23:17
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 a config param for enabling hard failure on doAs in Thriftserver when we do not support it.
Why are the changes needed?
People might expect doAs to run as a different user, which is not supported.
Does this PR introduce any user-facing change?
Explicit error unless config flag is disabled.
How was this patch tested?
New unit test.
Was this patch authored or co-authored using generative AI tooling?
Yes, claude