@@ -608,7 +608,10 @@ def test_model_columns():
608608 name = "target" , schema = "test" , database = "test" , account = "foo" , user = "bar" , password = "baz"
609609 )
610610 sqlmesh_model = model .to_sqlmesh (context )
611- assert sqlmesh_model .columns_to_types == expected_column_types
611+
612+ # Columns being present in a schema.yaml are not respected in DDLs, so SQLMesh doesn't
613+ # set the corresponding columns_to_types_ attribute either to match dbt's behavior
614+ assert sqlmesh_model .columns_to_types == None
612615 assert sqlmesh_model .column_descriptions == expected_column_descriptions
613616
614617
@@ -623,8 +626,11 @@ def test_seed_columns():
623626 },
624627 )
625628
629+ # dbt doesn't respect the data_type field in the DDLs– instead, it optionally uses it to
630+ # validate the actual data types at runtime through contracts or external plugins. Thus,
631+ # the actual data type is int, because that is what is inferred from the seed file.
626632 expected_column_types = {
627- "id" : exp .DataType .build ("text " ),
633+ "id" : exp .DataType .build ("int " ),
628634 "name" : exp .DataType .build ("text" ),
629635 }
630636 expected_column_descriptions = {
@@ -671,6 +677,27 @@ def test_seed_column_types():
671677 assert sqlmesh_seed .columns_to_types == expected_column_types
672678 assert sqlmesh_seed .column_descriptions == expected_column_descriptions
673679
680+ seed = SeedConfig (
681+ name = "foo" ,
682+ package = "package" ,
683+ path = Path ("examples/sushi_dbt/seeds/waiter_names.csv" ),
684+ column_types = {
685+ "name" : "text" ,
686+ },
687+ columns = {
688+ # The `data_type` field does not affect the materialized seed's column type
689+ "id" : ColumnConfig (name = "name" , data_type = "text" ),
690+ },
691+ quote_columns = True ,
692+ )
693+
694+ expected_column_types = {
695+ "id" : exp .DataType .build ("int" ),
696+ "name" : exp .DataType .build ("text" ),
697+ }
698+ sqlmesh_seed = seed .to_sqlmesh (context )
699+ assert sqlmesh_seed .columns_to_types == expected_column_types
700+
674701
675702def test_seed_column_inference (tmp_path ):
676703 seed_csv = tmp_path / "seed.csv"
0 commit comments