You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dbt explicitly implements a Decimal-aware JSON serializer, but it appears that there is more than one type of Decimal at play here. The agate library will optionally include the cdecimal version of Decimal if it is available (code here).
if isinstance(obj, Decimal):
return float(obj)
return super(JSONEncoder, self).default(obj)
here, Decimal is decimal.Decimal, but it could be that obj is of type cdecimal.Decimal. This leads to a confusing error.
Instead, dbt should check if the obj is of type decimal.Decimal or cdecimal.Decimal.
I think the Anaconda part of this is crucial, as I'm unsure how else someone might have cdecimal installed in their system. You can install it manually with pip install m3-cdecimal.
Results
"/Users/xxx/anaconda2/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/Users/xxx/anaconda2/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/dbt/utils.py", line 481, in default
return super(JSONEncoder, self).default(obj)
File "/Users/xxx/anaconda2/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: Decimal('0') is not JSON serializable
System information
The output of dbt --version:
0.12.1
The operating system you're running on: OSX
The python version you're using (probably the output of python --version)
2.7.15 installed via Anaconda.
The text was updated successfully, but these errors were encountered:
Issue
Issue description
The
dbt test
command can fail with an error like:dbt explicitly implements a Decimal-aware JSON serializer, but it appears that there is more than one type of Decimal at play here. The
agate
library will optionally include thecdecimal
version of Decimal if it is available (code here).dbt does a check here that looks like:
here,
Decimal
isdecimal.Decimal
, but it could be thatobj
is of typecdecimal.Decimal
. This leads to a confusing error.Instead, dbt should check if the
obj
is of typedecimal.Decimal
orcdecimal.Decimal
.I think the Anaconda part of this is crucial, as I'm unsure how else someone might have
cdecimal
installed in their system. You can install it manually withpip install m3-cdecimal
.Results
System information
The output of
dbt --version
:The operating system you're running on: OSX
The python version you're using (probably the output of
python --version
)2.7.15 installed via Anaconda.
The text was updated successfully, but these errors were encountered: