File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ def _get_dbt_version() -> t.Tuple[int, int]:
1313DBT_VERSION = _get_dbt_version ()
1414
1515if DBT_VERSION < (1 , 8 ):
16- from dbt .clients .agate_helper import table_from_data , empty_table , as_matrix # type: ignore # noqa: F401
16+ from dbt .clients .agate_helper import table_from_data_flat , empty_table , as_matrix # type: ignore # noqa: F401
1717else :
18- from dbt_common .clients .agate_helper import table_from_data , empty_table , as_matrix # type: ignore # noqa: F401
18+ from dbt_common .clients .agate_helper import table_from_data_flat , empty_table , as_matrix # type: ignore # noqa: F401
1919
2020
2121def pandas_to_agate (df : pd .DataFrame ) -> agate .Table :
2222 """
2323 Converts a Pandas DataFrame to an Agate Table
2424 """
2525
26- return table_from_data (df .to_dict (orient = "records" ), df .columns .tolist ())
26+ return table_from_data_flat (df .to_dict (orient = "records" ), df .columns .tolist ())
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ import pandas as pd
4+ from sqlmesh .dbt .util import pandas_to_agate
5+
6+
7+ def test_pandas_to_agate_type_coercion ():
8+ df = pd .DataFrame ({"data" : ["_2024_01_01" , "_2024_01_02" , "_2024_01_03" ]})
9+ agate_rows = pandas_to_agate (df ).rows
10+
11+ values = [v [0 ] for v in agate_rows .values ()]
12+ assert values == ["_2024_01_01" , "_2024_01_02" , "_2024_01_03" ]
You can’t perform that action at this time.
0 commit comments