You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Using Spark SQL Magic Commands (Jupyter Notebooks)
58
+
59
+
The package supports the [sparksql-magic](https://github.com/cryeo/sparksql-magic) library for executing Spark SQL queries directly in Jupyter notebooks.
60
+
61
+
**Installation**: To use magic commands, install the required dependencies manually:
62
+
```bash
63
+
pip install dataproc-spark-connect
64
+
pip install IPython sparksql-magic
65
+
```
66
+
67
+
1. Load the magic extension:
68
+
```python
69
+
%load_ext sparksql_magic
70
+
```
71
+
72
+
2. Configure default settings (optional):
73
+
```python
74
+
%config SparkSql.limit=20
75
+
```
76
+
77
+
3. Execute SQL queries:
78
+
```python
79
+
%%sparksql
80
+
SELECT*FROM your_table
81
+
```
82
+
83
+
4. Advanced usage with options:
84
+
```python
85
+
# Cache results and create a view
86
+
%%sparksql --cache --view result_view df
87
+
SELECT*FROM your_table WHERE condition = true
88
+
```
89
+
90
+
Available options:
91
+
-`--cache` / `-c`: Cache the DataFrame
92
+
-`--eager` / `-e`: Cache with eager loading
93
+
-`--view VIEW` / `-v VIEW`: Create a temporary view
See [sparksql-magic](https://github.com/cryeo/sparksql-magic) for more examples.
98
+
99
+
**Note**: Magic commands are optional. If you only need basic DataprocSparkSession functionality without Jupyter magic support, install only the base package:
100
+
```bash
101
+
pip install dataproc-spark-connect
102
+
```
103
+
57
104
## Developing
58
105
59
106
For development instructions see [guide](DEVELOPING.md).
0 commit comments