1+ import agate
2+ from datetime import datetime
13import json
24import logging
35import typing as t
3436from sqlmesh .dbt .model import Materialization , ModelConfig
3537from sqlmesh .dbt .project import Project
3638from sqlmesh .dbt .relation import Policy
37- from sqlmesh .dbt .seed import SeedConfig
39+ from sqlmesh .dbt .seed import SeedConfig , Integer
3840from sqlmesh .dbt .target import BigQueryConfig , DuckDbConfig , SnowflakeConfig
3941from sqlmesh .dbt .test import TestConfig
4042from sqlmesh .utils .errors import ConfigError , MacroEvalError , SQLMeshError
@@ -402,6 +404,7 @@ def test_seed_column_inference(tmp_path):
402404 fd .write ("int_col,double_col,datetime_col,date_col,boolean_col,text_col\n " )
403405 fd .write ("1,1.2,2021-01-01 00:00:00,2021-01-01,true,foo\n " )
404406 fd .write ("2,2.3,2021-01-02 00:00:00,2021-01-02,false,bar\n " )
407+ fd .write ("null,,null,,,null\n " )
405408
406409 seed = SeedConfig (
407410 name = "test_model" ,
@@ -423,6 +426,23 @@ def test_seed_column_inference(tmp_path):
423426 }
424427
425428
429+ def test_agate_integer_cast ():
430+ agate_integer = Integer (null_values = ("null" , "" ))
431+ assert agate_integer .cast ("1" ) == 1
432+ assert agate_integer .cast (1 ) == 1
433+ assert agate_integer .cast ("null" ) is None
434+ assert agate_integer .cast ("" ) is None
435+
436+ with pytest .raises (agate .exceptions .CastError ):
437+ agate_integer .cast ("1.2" )
438+
439+ with pytest .raises (agate .exceptions .CastError ):
440+ agate_integer .cast (1.2 )
441+
442+ with pytest .raises (agate .exceptions .CastError ):
443+ agate_integer .cast (datetime .now ())
444+
445+
426446@pytest .mark .xdist_group ("dbt_manifest" )
427447def test_model_dialect (sushi_test_project : Project , assert_exp_eq ):
428448 model_config = ModelConfig (
0 commit comments