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 @@ -2866,8 +2866,12 @@ def render_field_value(value: t.Any) -> t.Any:
28662866 for key , value in field_value .items ():
28672867 if key in RUNTIME_RENDERED_MODEL_FIELDS :
28682868 rendered_dict [key ] = parse_strings_with_macro_refs (value , dialect )
2869- elif key == "auto_restatement_cron" :
2870- # Don't parse auto_restatement_cron="@..." kwarg (e.g. @daily) into MacroVar
2869+ elif (
2870+ # don't parse kind auto_restatement_cron="@..." kwargs (e.g. @daily) into MacroVar
2871+ key == "auto_restatement_cron"
2872+ and isinstance (value , str )
2873+ and value .lower () in CRON_SHORTCUTS
2874+ ):
28712875 rendered_dict [key ] = value
28722876 elif (rendered := render_field_value (value )) is not None :
28732877 rendered_dict [key ] = rendered
Original file line number Diff line number Diff line change @@ -2920,6 +2920,28 @@ def my_model(context):
29202920 assert not mock_logger .call_args
29212921
29222922
2923+ def test_python_model_decorator_auto_restatement_cron () -> None :
2924+ @model (
2925+ "auto_restatement_model" ,
2926+ cron = "@daily" ,
2927+ kind = dict (
2928+ name = ModelKindName .INCREMENTAL_BY_TIME_RANGE ,
2929+ time_column = "ds" ,
2930+ auto_restatement_cron = "@hourly" ,
2931+ ),
2932+ columns = {'"ds"' : "date" , '"COL"' : "int" },
2933+ )
2934+ def my_model (context ):
2935+ pass
2936+
2937+ python_model = model .get_registry ()["auto_restatement_model" ].model (
2938+ module_path = Path ("." ),
2939+ path = Path ("." ),
2940+ )
2941+
2942+ assert python_model .auto_restatement_cron == "@hourly"
2943+
2944+
29232945def test_python_model_decorator_col_descriptions () -> None :
29242946 # `columns` and `column_descriptions` column names are different cases, but name normalization makes both lower
29252947 @model ("col_descriptions" , columns = {"col" : "int" }, column_descriptions = {"COL" : "a column" })
You can’t perform that action at this time.
0 commit comments