@@ -3757,7 +3757,10 @@ def my_model(context, **kwargs):
37573757 """('key_a' = 'value_a', 'key_b' = 1, 'key_c' = TRUE, 'key_d' = 2.0)"""
37583758 )
37593759
3760- with pytest .raises (ConfigError , match = r"Invalid property 'invalid'.*" ):
3760+ with pytest .raises (
3761+ ConfigError ,
3762+ match = r"Invalid property 'invalid'. Properties must be specified as key-value pairs <key> = <value>. " ,
3763+ ):
37613764 load_sql_based_model (
37623765 d .parse (
37633766 """
@@ -4418,6 +4421,108 @@ def test_model_session_properties(sushi_context):
44184421 "warehouse" : "test_warehouse" ,
44194422 }
44204423
4424+ model = load_sql_based_model (
4425+ d .parse (
4426+ """
4427+ MODEL (
4428+ name test_schema.test_model,
4429+ session_properties (
4430+ 'query_label' = [
4431+ ('key1', 'value1'),
4432+ ('key2', 'value2')
4433+ ]
4434+ )
4435+ );
4436+ SELECT a FROM tbl;
4437+ """ ,
4438+ default_dialect = "bigquery" ,
4439+ )
4440+ )
4441+ assert model .session_properties == {
4442+ "query_label" : parse_one ("[('key1', 'value1'), ('key2', 'value2')]" )
4443+ }
4444+
4445+ model = load_sql_based_model (
4446+ d .parse (
4447+ """
4448+ MODEL (
4449+ name test_schema.test_model,
4450+ session_properties (
4451+ 'query_label' = (
4452+ ('key1', 'value1')
4453+ )
4454+ )
4455+ );
4456+ SELECT a FROM tbl;
4457+ """ ,
4458+ default_dialect = "bigquery" ,
4459+ )
4460+ )
4461+ assert model .session_properties == {"query_label" : parse_one ("(('key1', 'value1'))" )}
4462+
4463+ with pytest .raises (
4464+ ConfigError ,
4465+ match = r"Invalid value for `session_properties.query_label`. Must be an array or tuple." ,
4466+ ):
4467+ load_sql_based_model (
4468+ d .parse (
4469+ """
4470+ MODEL (
4471+ name test_schema.test_model,
4472+ session_properties (
4473+ 'query_label' = 'invalid value'
4474+ )
4475+ );
4476+ SELECT a FROM tbl;
4477+ """ ,
4478+ default_dialect = "bigquery" ,
4479+ )
4480+ )
4481+
4482+ with pytest .raises (
4483+ ConfigError ,
4484+ match = r"Invalid entry in `session_properties.query_label`. Must be tuples of string literals with length 2." ,
4485+ ):
4486+ load_sql_based_model (
4487+ d .parse (
4488+ """
4489+ MODEL (
4490+ name test_schema.test_model,
4491+ session_properties (
4492+ 'query_label' = (
4493+ ('key1', 'value1', 'another_value')
4494+ )
4495+ )
4496+ );
4497+ SELECT a FROM tbl;
4498+ """ ,
4499+ default_dialect = "bigquery" ,
4500+ )
4501+ )
4502+
4503+ with pytest .raises (
4504+ ConfigError ,
4505+ match = r"Invalid entry in `session_properties.query_label`. Must be tuples of string literals with length 2." ,
4506+ ):
4507+ load_sql_based_model (
4508+ d .parse (
4509+ """
4510+ MODEL (
4511+ name test_schema.test_model,
4512+ session_properties (
4513+ 'query_label' = (
4514+ 'some value',
4515+ 'another value',
4516+ 'yet another value',
4517+ )
4518+ )
4519+ );
4520+ SELECT a FROM tbl;
4521+ """ ,
4522+ default_dialect = "bigquery" ,
4523+ )
4524+ )
4525+
44214526
44224527def test_model_jinja_macro_rendering ():
44234528 expressions = d .parse (
0 commit comments