Skip to content

Commit

Permalink
Change pyspark imports to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
icexelloss committed Aug 22, 2019
1 parent 26b041c commit 1f9409b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ibis/pyspark/tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import pandas as pd
import pandas.util.testing as tm
import pyspark.sql.functions as F
import pytest
from pyspark.sql import SparkSession
from pyspark.sql.window import Window

import ibis

pytestmark = pytest.mark.pyspark
pytest.importorskip('pyspark')


@pytest.fixture(scope='session')
def client():
pytest.importorskip('pyspark')
from pyspark.sql import SparkSession
import pyspark.sql.functions as F

session = SparkSession.builder.getOrCreate()
client = ibis.pyspark.connect(session)
df = client._session.range(0, 10)
Expand Down Expand Up @@ -72,6 +72,8 @@ def test_aggregation_col(client):


def test_aggregation(client):
import pyspark.sql.functions as F

table = client.table('table1')
result = table.aggregate(table['id'].max()).compile()
expected = table.compile().agg(F.max('id'))
Expand All @@ -80,6 +82,8 @@ def test_aggregation(client):


def test_groupby(client):
import pyspark.sql.functions as F

table = client.table('table1')
result = table.groupby('id').aggregate(table['id'].max()).compile()
expected = table.compile().groupby('id').agg(F.max('id'))
Expand All @@ -88,6 +92,9 @@ def test_groupby(client):


def test_window(client):
import pyspark.sql.functions as F
from pyspark.sql.window import Window

table = client.table('table1')
w = ibis.window()
result = (
Expand Down

0 comments on commit 1f9409b

Please sign in to comment.