---
title: sparkContext
description: "SparkSession.sparkContext property in PySpark: Returns the underlying SparkContext."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/sparksession/sparkContext
---

# sparkContext

Returns the underlying `SparkContext`.

## Syntax

```
sparkContext
```

## Returns

`SparkContext`

## Examples

> [!NOTE]
>
> `spark.sparkContext` is not available on Databricks Serverless compute. Use the `spark` (SparkSession) APIs directly: for example, `spark.createDataFrame(...)` in place of `spark.sparkContext.parallelize(...)`.

```python
spark.sparkContext
# <SparkContext master=... appName=...>

# Create an RDD from the Spark context.
rdd = spark.sparkContext.parallelize([1, 2, 3])
rdd.collect()
# [1, 2, 3]
```
