Skip to content

Commit 6720823

Browse files
committed
SEDONA-725 Add pyflink to Sedona.
1 parent 5536be4 commit 6720823

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

python/tests/flink/conftest.py

+29-26
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,38 @@
22

33
import pytest
44

5-
try:
6-
from sedona.flink import SedonaContext
7-
except ImportError:
8-
pass
9-
10-
from pyflink.datastream import StreamExecutionEnvironment
11-
from pyflink.table import EnvironmentSettings, StreamTableEnvironment
12-
135

146
EXTRA_JARS = os.getenv("SEDONA_PYFLINK_EXTRA_JARS")
157

168

17-
@pytest.fixture(scope="module")
18-
def flink_settings():
19-
return EnvironmentSettings.in_streaming_mode()
20-
9+
def has_pyflink():
10+
try:
11+
import pyflink
12+
except ImportError:
13+
return False
14+
return True
2115

22-
@pytest.fixture(scope="module")
23-
def stream_env() -> StreamExecutionEnvironment:
24-
env = StreamExecutionEnvironment.get_execution_environment()
25-
jars = EXTRA_JARS.split(",") if EXTRA_JARS else []
26-
for jar in jars:
27-
env.add_jars(f"file://{jar}")
2816

29-
return env
30-
31-
32-
@pytest.fixture(scope="module")
33-
def table_env(
34-
stream_env: StreamExecutionEnvironment, flink_settings: EnvironmentSettings
35-
) -> StreamTableEnvironment:
36-
return SedonaContext.create(stream_env, flink_settings)
17+
if has_pyflink():
18+
from sedona.flink import SedonaContext
19+
from pyflink.datastream import StreamExecutionEnvironment
20+
from pyflink.table import EnvironmentSettings, StreamTableEnvironment
21+
22+
@pytest.fixture(scope="module")
23+
def flink_settings():
24+
return EnvironmentSettings.in_streaming_mode()
25+
26+
@pytest.fixture(scope="module")
27+
def stream_env() -> StreamExecutionEnvironment:
28+
env = StreamExecutionEnvironment.get_execution_environment()
29+
jars = EXTRA_JARS.split(",") if EXTRA_JARS else []
30+
for jar in jars:
31+
env.add_jars(f"file://{jar}")
32+
33+
return env
34+
35+
@pytest.fixture(scope="module")
36+
def table_env(
37+
stream_env: StreamExecutionEnvironment, flink_settings: EnvironmentSettings
38+
) -> StreamTableEnvironment:
39+
return SedonaContext.create(stream_env, flink_settings)

0 commit comments

Comments
 (0)