Skip to content

Commit b4bb03b

Browse files
committed
feat: add agate table support in to_dict function
1 parent 6d1b255 commit b4bb03b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dbt_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@
1010
from collections.abc import Iterable
1111
from datetime import date, datetime, time
1212

13+
try:
14+
import agate
15+
HAS_AGATE = True
16+
except ImportError:
17+
HAS_AGATE = False
18+
1319

1420
def to_dict(obj):
21+
if HAS_AGATE and isinstance(obj, agate.Table):
22+
return {
23+
"rows": [to_dict(row) for row in obj.rows],
24+
"column_names": obj.column_names,
25+
"column_types": list(map(lambda x: x.__class__.__name__, obj.column_types)),
26+
}
1527
if isinstance(obj, str):
1628
return obj
1729
if isinstance(obj, Decimal):

0 commit comments

Comments
 (0)