@@ -3990,3 +3990,39 @@ def _set_config(gateway: str, config: Config) -> None:
39903990 was_evaluated = True ,
39913991 day_delta = 4 ,
39923992 )
3993+
3994+
3995+ def test_unicode_characters (ctx : TestContext , tmp_path : Path ):
3996+ if ctx .dialect in ["spark" , "trino" ]:
3997+ # It is possible that Trino could support this if we changed `QUOTE_IDENTIFIERS_IN_VIEWS` but that would
3998+ # break the compatibility it has when be mixed with Spark for compute
3999+ pytest .skip ("Skipping as these engines have issues with unicode characters in model names" )
4000+
4001+ model_name = "客户数据"
4002+ table = ctx .table (model_name ).sql (dialect = ctx .dialect )
4003+ (tmp_path / "models" ).mkdir (exist_ok = True )
4004+
4005+ model_def = f"""
4006+ MODEL (
4007+ name { table } ,
4008+ kind FULL,
4009+ dialect '{ ctx .dialect } '
4010+ );
4011+ SELECT 1 as id
4012+ """
4013+
4014+ (tmp_path / "models" / "客户数据.sql" ).write_text (model_def )
4015+
4016+ context = ctx .create_context (path = tmp_path )
4017+ context .plan (auto_apply = True , no_prompts = True )
4018+
4019+ results = ctx .get_metadata_results ()
4020+ assert len (results .views ) == 1
4021+ assert results .views [0 ].lower () == model_name
4022+
4023+ schema = d .to_schema (ctx .schema (), dialect = ctx .dialect )
4024+ schema_name = schema .args ["db" ].this
4025+ schema .args ["db" ].set ("this" , "sqlmesh__" + schema_name )
4026+ table_results = ctx .get_metadata_results (schema )
4027+ assert len (table_results .tables ) == 1
4028+ assert table_results .tables [0 ].lower ().startswith (schema_name + "________" )
0 commit comments