Skip to content

[MINOR][CONNECT] Remove redundant user_context.user_id assignment in execute_command methods#57493

Open
ybapat wants to merge 2 commits into
apache:masterfrom
ybapat:issue-56408-dup-user-context
Open

[MINOR][CONNECT] Remove redundant user_context.user_id assignment in execute_command methods#57493
ybapat wants to merge 2 commits into
apache:masterfrom
ybapat:issue-56408-dup-user-context

Conversation

@ybapat

@ybapat ybapat commented Jul 24, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

Remove two redundant assignments of req.user_context.user_id = self._user_id from SparkConnectClient.execute_command and SparkConnectClient.execute_command_as_iterator.

Both methods call _execute_plan_request_with_metadata() to build the request, and that helper already sets req.user_context.user_id under the identical if self._user_id: guard. The subsequent reassignments in the two callers are dead code.

# _execute_plan_request_with_metadata() already does this:
if self._user_id:
    req.user_context.user_id = self._user_id

# These lines in execute_command / execute_command_as_iterator were redundant:
- if self._user_id:
-     req.user_context.user_id = self._user_id

Relates to GitHub issue #56408.

Why are the changes needed?

Dead code removal / readability improvement. Setting the same protobuf field to the same value twice in sequence is misleading — it implies the first assignment might not be sufficient when it is.

Does this PR introduce any user-facing change?

No. The resulting req.user_context.user_id value is identical before and after this change.

How was this patch tested?

No behavior change; existing Spark Connect unit tests cover execute_command / execute_command_as_iterator request construction.

This PR was created with the assistance of Claude (AI). Disclosed per Apache Spark contribution guidelines.

…nt in execute_command methods

_execute_plan_request_with_metadata() already sets req.user_context.user_id
from self._user_id. The two execute_command methods were repeating this
assignment immediately after the call, which is dead code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ybapat for dead code removal! cc @Yicong-Huang @HyukjinKwon

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