Skip to content

Commit cede265

Browse files
Python Client
1 parent 271dfa6 commit cede265

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

docs/css/code.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
code {
2+
white-space: pre-wrap !important;
3+
}

docs/pyspark/.pages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
title: PySpark SQL
1+
title: Python Client
22
nav:
33
- index.md
44
- ...

docs/pyspark/index.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,60 @@
1-
# Spark Connect Client's Python API
1+
# Spark Connect Python Client
22

3-
`pyspark.sql.connect` module is the official Python API of Spark Connect Client.
3+
**Spark Connect Python Client** is the Python API of Spark Connect Client.
4+
5+
Spark Connect Python Client is in `pyspark.sql.connect` module.
6+
7+
## Demo
8+
9+
Start [Spark Connect Server](../server/index.md).
10+
11+
```bash
12+
./sbin/start-connect-server.sh
13+
```
14+
15+
Monitor the logs.
16+
17+
```bash
18+
tail -f logs/spark-*-org.apache.spark.sql.connect.service.SparkConnectServer-*.local.out
19+
```
20+
21+
Open the web UI (at http://localhost:4040/connect/) to monitor sessions and requests.
22+
23+
Connect to the local Spark Connect Server with PySpark Shell (`pyspark`).
424

525
```bash
626
uv run --with "pyspark-connect==4.0.0.dev2" \
7-
./bin/pyspark --remote "sc://localhost"
27+
./bin/pyspark --remote "sc://localhost:15002"
28+
```
29+
30+
```py
31+
>>> type(spark)
32+
<class 'pyspark.sql.connect.session.SparkSession'>
33+
```
34+
35+
```py
36+
>>> spark.version
37+
'4.0.0-SNAPSHOT'
38+
```
39+
40+
```py
41+
>>> spark.session_id
42+
'06c3b85b-775a-4438-a539-0a8ef301e00c'
43+
```
44+
45+
```py
46+
>>> dir(spark)
47+
['Builder', '__annotations__', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_active_session', '_cache_local_relation', '_client', '_create_remote_dataframe', '_default_session', '_getActiveSessionIfMatches', '_get_default_session', '_inferSchemaFromList', '_lock', '_parse_ddl', '_profiler_collector', '_session_id', '_set_default_and_active_session', '_start_connect_server', '_to_ddl', 'active', 'addArtifact', 'addArtifacts', 'addTag', 'builder', 'catalog', 'clearProgressHandlers', 'clearTags', 'client', 'conf', 'copyFromLocalToFs', 'createDataFrame', 'dataSource', 'getActiveSession', 'getTags', 'interruptAll', 'interruptOperation', 'interruptTag', 'is_stopped', 'profile', 'range', 'read', 'readStream', 'registerProgressHandler', 'release_session_on_close', 'removeProgressHandler', 'removeTag', 'session_id', 'sql', 'stop', 'streams', 'table', 'tvf', 'udf', 'udtf', 'version']
48+
```
49+
50+
```py
51+
>>> spark._client
52+
<pyspark.sql.connect.client.core.SparkConnectClient object at 0x111d6ca90>
53+
```
54+
55+
```py
56+
>>> dir(spark._client)
57+
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_analyze', '_analyze_plan_request_with_metadata', '_artifact_manager', '_build_metrics', '_build_observed_metrics', '_builder', '_channel', '_closed', '_config_request_with_metadata', '_create_profile', '_display_server_stack_trace', '_execute', '_execute_and_fetch', '_execute_and_fetch_as_iterator', '_execute_plan_request_with_metadata', '_fetch_enriched_error', '_handle_error', '_handle_rpc_error', '_interrupt_request', '_profiler_collector', '_progress_handlers', '_proto_to_string', '_resources', '_retry_policies', '_retrying', '_server_session_id', '_session_id', '_stub', '_throw_if_invalid_tag', '_truncate', '_use_reattachable_execute', '_user_id', '_verify_response_integrity', 'add_artifacts', 'add_tag', 'cache_artifact', 'clear_progress_handlers', 'clear_tags', 'close', 'config', 'copy_from_local_to_fs', 'disable_reattachable_execute', 'enable_reattachable_execute', 'execute_command', 'execute_command_as_iterator', 'explain_string', 'get_config_dict', 'get_config_with_defaults', 'get_configs', 'get_retry_policies', 'get_tags', 'host', 'interrupt_all', 'interrupt_operation', 'interrupt_tag', 'is_closed', 'register_data_source', 'register_java', 'register_progress_handler', 'register_udf', 'register_udtf', 'release_session', 'remove_progress_handler', 'remove_tag', 'same_semantics', 'schema', 'semantic_hash', 'set_retry_policies', 'thread_local', 'to_pandas', 'to_table', 'to_table_as_iterator', 'token']
858
```
959

1060
```py

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ extra:
123123
github: https://github.com/apache/spark/tree/master
124124
jira: https://issues.apache.org/jira/browse
125125

126+
extra_css:
127+
- css/code.css
128+
126129
nav:
127130
- index.md
128131
- Internals:

0 commit comments

Comments
 (0)