This is an automated email from the ASF dual-hosted git repository.

HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git


The following commit(s) were added to refs/heads/master by this push:
     new 8b7b548  [SPARK-60942][CONNECT] Share request user context construction
8b7b548 is described below

commit 8b7b5482714787df3d9facee3464e0949bdb14cc
Author: DB Tsai <[email protected]>
AuthorDate: Sun Nov 8 05:25:35 2026 +0900

    [SPARK-60942][CONNECT] Share request user context construction
    
    ### What changes were proposed in this pull request?
    
    Share one private constructor for missing typed-request user contexts and 
artifact upload/status contexts. Preserve explicit caller IDs, names and 
extensions.
    
    Other convenience RPC builders are unchanged. This follows #164 under 
[SPARK-60942](https://issues.apache.org/jira/browse/SPARK-60942).
    
    ### Why are the changes needed?
    
    Keep request identity construction consistent without changing the request 
bodies.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    - `git diff --check` passes.
    - Existing user-context and artifact wire tests cover the preserved 
default, configured and explicit identity behavior; those tests were inspected 
during source review.
    - The complete patch received an independent source review, including the 
final documentation update.
    - **Draft: required runtime validation is pending.** Cargo is unavailable 
in the local environment. Rust tests, integration-test compilation with and 
without `wasm-udf`, rustfmt, Clippy, API introspection and the official parity 
gate have not passed in this session.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: OpenAI Codex
    
    This pull request and its description were written by OpenAI Codex.
    
    Closes #299 from dbtsai/codex/postmerge-pr-164-artifact-context-cleanup.
    
    Authored-by: DB Tsai <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 crates/spark-connect-core/src/client.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/crates/spark-connect-core/src/client.rs 
b/crates/spark-connect-core/src/client.rs
index 98ab0cb..3552b86 100644
--- a/crates/spark-connect-core/src/client.rs
+++ b/crates/spark-connect-core/src/client.rs
@@ -1310,7 +1310,7 @@ impl SparkConnectClient {
     /// explicit user ID, the user name and the extensions are kept; raw 
requests are sent
     /// as given.
     fn fill_user_context(&self, context: &mut Option<UserContext>) {
-        let context = context.get_or_insert_with(UserContext::default);
+        let context = context.get_or_insert_with(|| self.new_user_context());
         if context.user_id.is_empty() {
             if let Some(user_id) = &self.user_id {
                 context.user_id.clone_from(user_id);
@@ -1318,9 +1318,9 @@ impl SparkConnectClient {
         }
     }
 
-    /// PySpark and Scala ArtifactManager both send a UserContext even when no
-    /// user ID is configured.
-    fn artifact_user_context(&self) -> UserContext {
+    /// Build a fresh request context, even when no user ID is configured.
+    /// PySpark and Scala both send a present context on artifact requests.
+    fn new_user_context(&self) -> UserContext {
         UserContext {
             user_id: self.user_id.clone().unwrap_or_default(),
             ..Default::default()
@@ -1361,7 +1361,7 @@ impl SparkConnectClient {
         &self,
         requests: impl Iterator<Item = 
spark_connect_proto::AddArtifactsRequest> + Send + 'static,
     ) -> std::result::Result<spark_connect_proto::AddArtifactsResponse, 
tonic::Status> {
-        let user_context = self.artifact_user_context();
+        let user_context = self.new_user_context();
         let client_type = self.user_agent.clone();
         let requests = requests.map(move |mut request| {
             request.user_context = Some(user_context.clone());
@@ -1397,7 +1397,7 @@ impl SparkConnectClient {
     ) -> std::result::Result<std::collections::HashMap<String, bool>, 
tonic::Status> {
         let mut request = ArtifactStatusesRequest::default();
         request.session_id = self.session_id.clone();
-        request.user_context = Some(self.artifact_user_context());
+        request.user_context = Some(self.new_user_context());
         request.client_type = Some(self.user_agent.clone());
         request.names = names.to_vec();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to