Skip to content

Commit

Permalink
Update workflows & pytest to choose the Sparksession instance based o…
Browse files Browse the repository at this point in the history
…n a condition
  • Loading branch information
nijanthanvijayakumar committed Jul 15, 2024
1 parent b5f6749 commit 6cdd1d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ jobs:
- name: Run tests with pytest against PySpark ${{ matrix.pyspark-version }}
run: make test

- name: Run tests using Spark-Connect
- name: Run tests using Spark-Connect against PySpark ${{ matrix.pyspark-version }}
env:
HADOOP_VERSION: 3
SPARK_VERSION: ${{ matrix.pyspark-version }}
SPARK_CONNECT_MODE_ENABLE: 1
run: |
if [[ "${SPARK_VERSION}" > "3.4" ]]; then
sh scripts/run_spark_connect_server.sh
Expand Down
6 changes: 5 additions & 1 deletion tests/spark.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import os
from pyspark.sql import SparkSession

spark = SparkSession.builder.master("local").appName("chispa").getOrCreate()
if "SPARK_CONNECT_MODE_ENABLE" in os.environ:
spark = SparkSession.builder.remote("sc://localhost:15002").getOrCreate()
else:
spark = SparkSession.builder.master("local").appName("chispa").getOrCreate()
10 changes: 2 additions & 8 deletions tests/test_spark_connect.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import pytest
import chispa
from pyspark.sql import SparkSession
from pyspark.sql.types import IntegerType, StringType, StructField, StructType

import quinn
from .spark import spark


@pytest.fixture(scope="module")
def spark():
return SparkSession.builder.remote("sc://localhost:15002").getOrCreate()


def test_create_df(spark):
def test_create_df():
rows_data = [("abc", 1), ("lu", 2), ("torrence", 3)]
col_specs = [("name", StringType()), ("age", IntegerType())]

Expand Down

0 comments on commit 6cdd1d2

Please sign in to comment.