File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -2810,8 +2810,12 @@ def render_field_value(value: t.Any) -> t.Any:
2810
2810
for key , value in field_value .items ():
2811
2811
if key in RUNTIME_RENDERED_MODEL_FIELDS :
2812
2812
rendered_dict [key ] = parse_strings_with_macro_refs (value , dialect )
2813
- elif key == "auto_restatement_cron" :
2814
- # Don't parse auto_restatement_cron="@..." kwarg (e.g. @daily) into MacroVar
2813
+ elif (
2814
+ # don't parse kind auto_restatement_cron="@..." kwargs (e.g. @daily) into MacroVar
2815
+ key == "auto_restatement_cron"
2816
+ and isinstance (value , str )
2817
+ and value .lower () in CRON_SHORTCUTS
2818
+ ):
2815
2819
rendered_dict [key ] = value
2816
2820
elif (rendered := render_field_value (value )) is not None :
2817
2821
rendered_dict [key ] = rendered
Original file line number Diff line number Diff line change @@ -2904,6 +2904,28 @@ def my_model(context):
2904
2904
assert not mock_logger .call_args
2905
2905
2906
2906
2907
+ def test_python_model_decorator_auto_restatement_cron () -> None :
2908
+ @model (
2909
+ "auto_restatement_model" ,
2910
+ cron = "@daily" ,
2911
+ kind = dict (
2912
+ name = ModelKindName .INCREMENTAL_BY_TIME_RANGE ,
2913
+ time_column = "ds" ,
2914
+ auto_restatement_cron = "@hourly" ,
2915
+ ),
2916
+ columns = {'"ds"' : "date" , '"COL"' : "int" },
2917
+ )
2918
+ def my_model (context ):
2919
+ pass
2920
+
2921
+ python_model = model .get_registry ()["auto_restatement_model" ].model (
2922
+ module_path = Path ("." ),
2923
+ path = Path ("." ),
2924
+ )
2925
+
2926
+ assert python_model .auto_restatement_cron == "@hourly"
2927
+
2928
+
2907
2929
def test_python_model_decorator_col_descriptions () -> None :
2908
2930
# `columns` and `column_descriptions` column names are different cases, but name normalization makes both lower
2909
2931
@model ("col_descriptions" , columns = {"col" : "int" }, column_descriptions = {"COL" : "a column" })
You can’t perform that action at this time.
0 commit comments