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 28509f29 [SPARK-61092][FOLLOWUP][CONNECT][PYTHON] Raise 
JVM_ATTRIBUTE_NOT_SUPPORTED for DataFrame.rdd, as pyspark-client does
28509f29 is described below

commit 28509f2911fb7b4838dba18a92e5a07f55eea7f6
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Fri Nov 13 15:13:54 2026 +0900

    [SPARK-61092][FOLLOWUP][CONNECT][PYTHON] Raise JVM_ATTRIBUTE_NOT_SUPPORTED 
for DataFrame.rdd, as pyspark-client does
    
    ### What changes were proposed in this pull request?
    
    A follow-up of SPARK-61092 (b54c3cd7), found in the r9 post-merge review. 
pyspark-client 4.3.0's Connect `DataFrame` defines its `rdd` property only `if 
not is_remote_only()` (`sql/connect/dataframe.py`), so in the remote-only 
client `df.rdd` goes to `DataFrame.__getattr__`. That raises 
`PySparkAttributeError [JVM_ATTRIBUTE_NOT_SUPPORTED]`, an `AttributeError`, so 
`hasattr(df, "rdd")` is `False`.
    
    The drop-in mirrors pyspark-client, but it had an `rdd` getter that raised 
`PySparkNotImplementedError [NOT_IMPLEMENTED]`. That is not an 
`AttributeError`, so `hasattr(df, "rdd")` raised. The getter is removed. The 
drop-in's `__getattr__`, which already lists `rdd` with `_jseq`, `_jdf`, 
`_jmap` and `_jcols`, then raises as pyspark-client does.
    
    ### Why are the changes needed?
    
    To match pyspark-client 4.3.0. `hasattr` and `getattr(df, "rdd", default)` 
must work, as they do there.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes, in the Python client. `df.rdd` raises `PySparkAttributeError 
[JVM_ATTRIBUTE_NOT_SUPPORTED]`, and `hasattr(df, "rdd")` is `False`, as in 
pyspark-client.
    
    ### How was this patch tested?
    
    - The test of the DataFrame attributes now checks `rdd` with the other JVM 
attributes, and that `hasattr(df, "rdd")` is false. It fails without the change.
    - A probe against a Spark 4.3.0 server gives the same result on official 
pyspark-client 4.3.0 and on this client.
    - The whole `test_dropin_offline.py` (1973 passed, 8 skipped), `cargo fmt 
--all --check` and ruff.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Opus 5.5
    
    This pull request and its description were written by Isaac.
    
    Closes #621 from HyukjinKwon/SPARK-61092-followup-rdd.
    
    Authored-by: Hyukjin Kwon <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 crates/pyspark-rs/src/dataframe.rs  | 12 ------------
 python/tests/test_dropin_offline.py | 10 +++++-----
 2 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/crates/pyspark-rs/src/dataframe.rs 
b/crates/pyspark-rs/src/dataframe.rs
index 43e2eebc..acde1133 100644
--- a/crates/pyspark-rs/src/dataframe.rs
+++ b/crates/pyspark-rs/src/dataframe.rs
@@ -2197,18 +2197,6 @@ impl PyDataFrame {
         self.spark_session(py)
     }
 
-    /// Not supported on Spark Connect, as PySpark Connect's: 
`NOT_IMPLEMENTED` of `rdd`, which
-    /// needs the RDD API of a classic session.
-    #[getter]
-    fn rdd(&self, py: Python<'_>) -> PyResult<()> {
-        Err(crate::column::raise_pyspark(
-            py,
-            "PySparkNotImplementedError",
-            "NOT_IMPLEMENTED",
-            &[("feature", "rdd")],
-        ))
-    }
-
     /// The EXISTS subquery of this DataFrame, as a Column. Mirrors 
`DataFrame.exists()`.
     fn exists(&self) -> PyColumn {
         PyColumn::new(self.dataframe.exists())
diff --git a/python/tests/test_dropin_offline.py 
b/python/tests/test_dropin_offline.py
index 8dff53db..2dfc2f5b 100644
--- a/python/tests/test_dropin_offline.py
+++ b/python/tests/test_dropin_offline.py
@@ -16909,7 +16909,6 @@ def 
test_dataframes_take_their_arguments_and_attributes_as_pyspark(mock_connect,
     # and JVM_ATTRIBUTE_NOT_SUPPORTED of those of a classic DataFrame.
     from pyspark.errors import (
         PySparkAttributeError,
-        PySparkNotImplementedError,
         PySparkTypeError,
         PySparkValueError,
     )
@@ -16935,13 +16934,14 @@ def 
test_dataframes_take_their_arguments_and_attributes_as_pyspark(mock_connect,
         assert e.value.getMessageParameters() == {
             "arg_name": arg_name, "expected_type": "str", "arg_type": arg_type}
     assert type(df._not_a_dunder).__name__ == "Column"
-    for name in ("_jseq", "_jdf", "_jmap", "_jcols"):
+    # `rdd` too: pyspark-client's DataFrame defines no `rdd` property (only a 
classic-capable
+    # PySpark does), so its `__getattr__` raises an AttributeError, and 
`hasattr` is False.
+    for name in ("_jseq", "_jdf", "_jmap", "_jcols", "rdd"):
         with pytest.raises(PySparkAttributeError) as e:
             getattr(df, name)
         assert e.value.getCondition() == "JVM_ATTRIBUTE_NOT_SUPPORTED"
-    with pytest.raises(PySparkNotImplementedError) as e:
-        df.rdd
-    assert e.value.getMessageParameters() == {"feature": "rdd"}
+        assert e.value.getMessageParameters() == {"attr_name": name}
+    assert not hasattr(df, "rdd")
     with pytest.raises(PySparkAttributeError) as e:
         df.__not_a_column__
     assert e.value.getCondition() == "ATTRIBUTE_NOT_SUPPORTED"


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

Reply via email to