You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "itholic (via GitHub)" <gi...@apache.org> on 2024/10/25 04:53:27 UTC

[PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

itholic opened a new pull request, #48651:
URL: https://github.com/apache/spark/pull/48651

   
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This PR proposes to make the compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT`
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   The current compatibility check cannot capture the missing methods that has `ONLY_SUPPORTED_WITH_SPARK_CONNECT` in its function body
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No, it's test-only
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Updated the existing UT
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1839069402


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -60,16 +60,23 @@
     from pyspark.sql.connect.streaming.readwriter import DataStreamReader as ConnectDataStreamReader
     from pyspark.sql.connect.streaming.readwriter import DataStreamWriter as ConnectDataStreamWriter
 
+SPARK_CONNECT_ONLY = "spark_connect_only"
+
 
 class ConnectCompatibilityTestsMixin:
     def get_public_methods(self, cls):
         """Get public methods of a class."""
-        return {
-            name: method
-            for name, method in inspect.getmembers(cls)
-            if (inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper))
-            and not name.startswith("_")
-        }
+        methods = {}
+        for name, method in inspect.getmembers(cls):
+            if (
+                inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper)
+            ) and not name.startswith("_"):
+                source_lines = inspect.getsource(method).upper()
+                if "ONLY_SUPPORTED_WITH_SPARK_CONNECT" in source_lines:

Review Comment:
   > How about using a new decorator @SparkConnectOnly
   
   It sounds like a reasonable suggestion.
   Let me create a separate PR and will ping you guys when it's ready.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1817691916


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -60,16 +60,23 @@
     from pyspark.sql.connect.streaming.readwriter import DataStreamReader as ConnectDataStreamReader
     from pyspark.sql.connect.streaming.readwriter import DataStreamWriter as ConnectDataStreamWriter
 
+SPARK_CONNECT_ONLY = "spark_connect_only"
+
 
 class ConnectCompatibilityTestsMixin:
     def get_public_methods(self, cls):
         """Get public methods of a class."""
-        return {
-            name: method
-            for name, method in inspect.getmembers(cls)
-            if (inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper))
-            and not name.startswith("_")
-        }
+        methods = {}
+        for name, method in inspect.getmembers(cls):
+            if (
+                inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper)
+            ) and not name.startswith("_"):
+                source_lines = inspect.getsource(method).upper()
+                if "ONLY_SUPPORTED_WITH_SPARK_CONNECT" in source_lines:

Review Comment:
   This is too flaky.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1815994121


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -249,7 +267,22 @@ def test_spark_session_compatibility(self):
         """Test SparkSession compatibility between classic and connect."""
         expected_missing_connect_properties = {"sparkContext"}
         expected_missing_classic_properties = {"is_stopped", "session_id"}
-        expected_missing_connect_methods = {"newSession"}
+        expected_missing_connect_methods = {
+            "addArtifact",
+            "addArtifacts",
+            "addTag",
+            "clearProgressHandlers",
+            "clearTags",
+            "copyFromLocalToFs",
+            "getTags",
+            "interruptAll",
+            "interruptOperation",
+            "interruptTag",
+            "newSession",
+            "registerProgressHandler",
+            "removeProgressHandler",
+            "removeTag",
+        }

Review Comment:
   Now the compatibility check respect the `ONLY_SUPPORTED_WITH_SPARK_CONNECT`.
   
   cc @HyukjinKwon @hvanhovell FYI



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Add `@remote_only` to check the APIs that only supported with Spark Connect [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic closed pull request #48651: [SPARK-50113][CONNECT][PYTHON][TESTS] Add `@remote_only` to check the APIs that only supported with Spark Connect
URL: https://github.com/apache/spark/pull/48651


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1820066066


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -60,16 +60,23 @@
     from pyspark.sql.connect.streaming.readwriter import DataStreamReader as ConnectDataStreamReader
     from pyspark.sql.connect.streaming.readwriter import DataStreamWriter as ConnectDataStreamWriter
 
+SPARK_CONNECT_ONLY = "spark_connect_only"
+
 
 class ConnectCompatibilityTestsMixin:
     def get_public_methods(self, cls):
         """Get public methods of a class."""
-        return {
-            name: method
-            for name, method in inspect.getmembers(cls)
-            if (inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper))
-            and not name.startswith("_")
-        }
+        methods = {}
+        for name, method in inspect.getmembers(cls):
+            if (
+                inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper)
+            ) and not name.startswith("_"):
+                source_lines = inspect.getsource(method).upper()
+                if "ONLY_SUPPORTED_WITH_SPARK_CONNECT" in source_lines:

Review Comment:
   Agree that it's flaky but I believe this is currently the only way to check functions that only supported from connect.
   Should we just close it? Also cc @hvanhovell 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

Posted by "xupefei (via GitHub)" <gi...@apache.org>.
xupefei commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1832731995


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -60,16 +60,23 @@
     from pyspark.sql.connect.streaming.readwriter import DataStreamReader as ConnectDataStreamReader
     from pyspark.sql.connect.streaming.readwriter import DataStreamWriter as ConnectDataStreamWriter
 
+SPARK_CONNECT_ONLY = "spark_connect_only"
+
 
 class ConnectCompatibilityTestsMixin:
     def get_public_methods(self, cls):
         """Get public methods of a class."""
-        return {
-            name: method
-            for name, method in inspect.getmembers(cls)
-            if (inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper))
-            and not name.startswith("_")
-        }
+        methods = {}
+        for name, method in inspect.getmembers(cls):
+            if (
+                inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper)
+            ) and not name.startswith("_"):
+                source_lines = inspect.getsource(method).upper()
+                if "ONLY_SUPPORTED_WITH_SPARK_CONNECT" in source_lines:

Review Comment:
   How about using a new decorator `@SparkConnectOnly` which doesn't suffer from flakiness? So instead of having a list in `test_spark_session_compatibility` we now spread the items to their declaration sites.
   That would make people more aware of adding such a decorator when needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1817692108


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -60,16 +60,23 @@
     from pyspark.sql.connect.streaming.readwriter import DataStreamReader as ConnectDataStreamReader
     from pyspark.sql.connect.streaming.readwriter import DataStreamWriter as ConnectDataStreamWriter
 
+SPARK_CONNECT_ONLY = "spark_connect_only"
+
 
 class ConnectCompatibilityTestsMixin:
     def get_public_methods(self, cls):
         """Get public methods of a class."""
-        return {
-            name: method
-            for name, method in inspect.getmembers(cls)
-            if (inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper))
-            and not name.startswith("_")
-        }
+        methods = {}
+        for name, method in inspect.getmembers(cls):
+            if (
+                inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper)
+            ) and not name.startswith("_"):
+                source_lines = inspect.getsource(method).upper()
+                if "ONLY_SUPPORTED_WITH_SPARK_CONNECT" in source_lines:

Review Comment:
   Let's probably don't do this for now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Compatibility check should respect `ONLY_SUPPORTED_WITH_SPARK_CONNECT` [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1823880564


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -60,16 +60,23 @@
     from pyspark.sql.connect.streaming.readwriter import DataStreamReader as ConnectDataStreamReader
     from pyspark.sql.connect.streaming.readwriter import DataStreamWriter as ConnectDataStreamWriter
 
+SPARK_CONNECT_ONLY = "spark_connect_only"
+
 
 class ConnectCompatibilityTestsMixin:
     def get_public_methods(self, cls):
         """Get public methods of a class."""
-        return {
-            name: method
-            for name, method in inspect.getmembers(cls)
-            if (inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper))
-            and not name.startswith("_")
-        }
+        methods = {}
+        for name, method in inspect.getmembers(cls):
+            if (
+                inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper)
+            ) and not name.startswith("_"):
+                source_lines = inspect.getsource(method).upper()
+                if "ONLY_SUPPORTED_WITH_SPARK_CONNECT" in source_lines:

Review Comment:
   I don't think we should rely on reading/checking the code itself in the test. This isn't what we meant for signature comparison / compatibility test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Add `@spark_connect_only` to check the APIs that only supported with Spark Connect [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1843103065


##########
python/pyspark/sql/tests/test_connect_compatibility.py:
##########
@@ -60,16 +60,23 @@
     from pyspark.sql.connect.streaming.readwriter import DataStreamReader as ConnectDataStreamReader
     from pyspark.sql.connect.streaming.readwriter import DataStreamWriter as ConnectDataStreamWriter
 
+SPARK_CONNECT_ONLY = "spark_connect_only"
+
 
 class ConnectCompatibilityTestsMixin:
     def get_public_methods(self, cls):
         """Get public methods of a class."""
-        return {
-            name: method
-            for name, method in inspect.getmembers(cls)
-            if (inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper))
-            and not name.startswith("_")
-        }
+        methods = {}
+        for name, method in inspect.getmembers(cls):
+            if (
+                inspect.isfunction(method) or isinstance(method, functools._lru_cache_wrapper)
+            ) and not name.startswith("_"):
+                source_lines = inspect.getsource(method).upper()
+                if "ONLY_SUPPORTED_WITH_SPARK_CONNECT" in source_lines:

Review Comment:
   @xupefei just applied the comments. Could you review again when you find some time? Thanks!
   
   Also cc @HyukjinKwon now we apply the `@spark_connect_only` decorator for APIs that are only supported with Spark Connect and use it from the testing instead of string comparison.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Add `@spark_connect_only` to check the APIs that only supported with Spark Connect [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1849897240


##########
python/pyspark/sql/session.py:
##########
@@ -550,6 +555,7 @@ def getOrCreate(self) -> "SparkSession":
                 return session
 
         # Spark Connect-specific API
+        @spark_connect_only

Review Comment:
   `spark_connect_only` -> `connect_only` or `remote_only` for naming consistency



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Add `@spark_connect_only` to check the APIs that only supported with Spark Connect [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #48651:
URL: https://github.com/apache/spark/pull/48651#discussion_r1851303941


##########
python/pyspark/sql/session.py:
##########
@@ -550,6 +555,7 @@ def getOrCreate(self) -> "SparkSession":
                 return session
 
         # Spark Connect-specific API
+        @spark_connect_only

Review Comment:
   Updated to `remote_only`. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-50113][CONNECT][PYTHON][TESTS] Add `@remote_only` to check the APIs that only supported with Spark Connect [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #48651:
URL: https://github.com/apache/spark/pull/48651#issuecomment-2490370330

   Merged to master. Thanks @HyukjinKwon @xupefei for the review!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org