Skip to content

[SPARK-59118][SQL] Error when doAs is used and not supported - #58414

Open
holdenk wants to merge 5 commits into
apache:masterfrom
holdenk:SPARK-59118-doAs-warn
Open

[SPARK-59118][SQL] Error when doAs is used and not supported#58414
holdenk wants to merge 5 commits into
apache:masterfrom
holdenk:SPARK-59118-doAs-warn

Conversation

@holdenk

@holdenk holdenk commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

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

sfc-gh-hkarau and others added 5 commits August 30, 2026 04:26
…, 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants