-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-40538] [CONNECT] Improve built-in function support for Python client. #38270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
dee4267
341d44e
b7902cb
b327268
4fe501e
bac0664
b7acacb
1c7b7ef
5675ff6
e03c60a
09f1540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,12 @@ | |
| import unittest | ||
| import tempfile | ||
|
|
||
| import pandas | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm .. we gotta fix this or do something. pandas isn't a required library for SQL package. Should probably skip this tests when pandas is not installed for now until we have a clear way to handle this. (see
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, nothing in Spark Connect will work atm without pandas because we always call |
||
|
|
||
| from pyspark.sql import SparkSession, Row | ||
| from pyspark.sql.connect.client import RemoteSparkSession | ||
| from pyspark.sql.connect.function_builder import udf | ||
| from pyspark.sql.connect.functions import lit | ||
| from pyspark.testing.connectutils import should_test_connect, connect_requirement_message | ||
| from pyspark.testing.utils import ReusedPySparkTestCase | ||
|
|
||
|
|
@@ -79,6 +82,15 @@ def test_simple_explain_string(self): | |
| result = df.explain() | ||
| self.assertGreater(len(result), 0) | ||
|
|
||
| def test_simple_binary_expressions(self): | ||
| """Test complex expression""" | ||
| df = self.connect.read.table(self.tbl_name) | ||
| pd = df.select(df.id).where(df.id % lit(30) == lit(0)).sort(df.id.asc()).toPandas() | ||
| self.assertEqual(len(pd.index), 4) | ||
|
|
||
| res = pandas.DataFrame(data={"id": [0, 30, 60, 90]}) | ||
| self.assert_(pd.equals(res), f"{pd.to_string()} != {res.to_string()}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| from pyspark.sql.tests.connect.test_connect_basic import * # noqa: F401 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.