Skip to content

Commit e38d06b

Browse files
grundprinzipHyukjinKwon
authored andcommitted
[SPARK-44740][CONNECT][FOLLOW] Fix metadata values in Python client
### What changes were proposed in this pull request? This is a follow-up PR that avoids putting the session ID into the metadata of the GRPC channel. ### Why are the changes needed? Behavhior ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? UT Closes apache#42452 from grundprinzip/SPARK-44740_v2. Authored-by: Martin Grund <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent 3ed9920 commit e38d06b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

python/pyspark/sql/connect/client/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ def metadata(self) -> Iterable[Tuple[str, str]]:
285285
ChannelBuilder.PARAM_USE_SSL,
286286
ChannelBuilder.PARAM_USER_ID,
287287
ChannelBuilder.PARAM_USER_AGENT,
288+
ChannelBuilder.PARAM_SESSION_ID,
288289
]
289290
]
290291

python/pyspark/sql/tests/connect/test_connect_basic.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3528,6 +3528,21 @@ def test_metadata(self):
35283528
chan = ChannelBuilder(f"sc://host/;session_id={id}")
35293529
self.assertEqual(id, chan.session_id)
35303530

3531+
chan = ChannelBuilder(f"sc://host/;session_id={id};user_agent=acbd;token=abcd;use_ssl=true")
3532+
md = chan.metadata()
3533+
for kv in md:
3534+
self.assertNotIn(
3535+
kv[0],
3536+
[
3537+
ChannelBuilder.PARAM_SESSION_ID,
3538+
ChannelBuilder.PARAM_TOKEN,
3539+
ChannelBuilder.PARAM_USER_ID,
3540+
ChannelBuilder.PARAM_USER_AGENT,
3541+
ChannelBuilder.PARAM_USE_SSL,
3542+
],
3543+
"Metadata must not contain fixed params",
3544+
)
3545+
35313546
with self.assertRaises(ValueError) as ve:
35323547
chan = ChannelBuilder("sc://host/;session_id=abcd")
35333548
SparkConnectClient(chan)

0 commit comments

Comments
 (0)