@@ -280,12 +280,22 @@ def test_change_task_version_blob(mocker):
280
280
child_spy .assert_called_once ()
281
281
282
282
283
- def test_change_lazy_query (mocker ):
283
+ @pytest .mark .parametrize (
284
+ "get_tbl_obj" ,
285
+ [
286
+ lambda query_value : select_as (query_value , "x" ),
287
+ (lambda query_value : pl .DataFrame ({"x" : [query_value ]})) if pl else None ,
288
+ ],
289
+ ids = ["sql" , "polars" ],
290
+ )
291
+ def test_change_lazy_query (mocker , get_tbl_obj ):
292
+ if get_tbl_obj is None :
293
+ pytest .skip ("Polars is not installed, skipping Polars test." )
284
294
query_value = 1
285
295
286
296
@materialize (lazy = True , nout = 2 )
287
297
def lazy_task ():
288
- return 0 , Table (select_as (query_value , "x" ), name = "lazy_table" )
298
+ return 0 , Table (get_tbl_obj (query_value ), name = "lazy_table" )
289
299
290
300
@materialize (input_type = pd .DataFrame , version = "1.0" )
291
301
def get_first (table , col ):
@@ -1045,35 +1055,3 @@ def get_flow():
1045
1055
# from a lazy task, hence res_constant should be cache valid and the task
1046
1056
# producing res_select should not be called.
1047
1057
constant_spy .assert_not_called ()
1048
-
1049
-
1050
- @pytest .mark .polars
1051
- def test_lazy_polars_dataframe (mocker ):
1052
- value = - 1
1053
-
1054
- @materialize (lazy = True )
1055
- def polars_task ():
1056
- return Table (pl .DataFrame ({"x" : [value ]}), name = "polars_table" )
1057
-
1058
- with Flow () as flow :
1059
- with Stage ("stage_1" ):
1060
- polars_table = polars_task ()
1061
- res_val = m .take_first (polars_table , as_int = True )
1062
-
1063
- # Initial Call for cache invalidation
1064
- with StageLockContext ():
1065
- res = flow .run ()
1066
- assert res .get (res_val ) == - 1
1067
-
1068
- # Change the value and run the flow again
1069
- value = 0
1070
- take_first_spy = spy_task (mocker , res_val )
1071
- with StageLockContext ():
1072
- res = flow .run ()
1073
- assert res .get (res_val ) == 0
1074
-
1075
- with StageLockContext ():
1076
- res = flow .run ()
1077
- assert res .get (res_val ) == 0
1078
-
1079
- take_first_spy .assert_called_once ()
0 commit comments