mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Handle 'pd.Timestamp' when jsonifying (#4275)
This commit is contained in:
parent
b72d5b03dc
commit
a0621e10a8
@ -34,6 +34,7 @@ from flask_babel import gettext as __
|
|||||||
from flask_cache import Cache
|
from flask_cache import Cache
|
||||||
import markdown as md
|
import markdown as md
|
||||||
import numpy
|
import numpy
|
||||||
|
import pandas as pd
|
||||||
import parsedatetime
|
import parsedatetime
|
||||||
from past.builtins import basestring
|
from past.builtins import basestring
|
||||||
from pydruid.utils.having import Having
|
from pydruid.utils.having import Having
|
||||||
@ -360,11 +361,7 @@ def json_iso_dttm_ser(obj, pessimistic=False):
|
|||||||
val = base_json_conv(obj)
|
val = base_json_conv(obj)
|
||||||
if val is not None:
|
if val is not None:
|
||||||
return val
|
return val
|
||||||
if isinstance(obj, datetime):
|
if isinstance(obj, (datetime, date, time, pd.Timestamp)):
|
||||||
obj = obj.isoformat()
|
|
||||||
elif isinstance(obj, date):
|
|
||||||
obj = obj.isoformat()
|
|
||||||
elif isinstance(obj, time):
|
|
||||||
obj = obj.isoformat()
|
obj = obj.isoformat()
|
||||||
else:
|
else:
|
||||||
if pessimistic:
|
if pessimistic:
|
||||||
@ -398,7 +395,7 @@ def json_int_dttm_ser(obj):
|
|||||||
val = base_json_conv(obj)
|
val = base_json_conv(obj)
|
||||||
if val is not None:
|
if val is not None:
|
||||||
return val
|
return val
|
||||||
if isinstance(obj, datetime):
|
if isinstance(obj, (datetime, pd.Timestamp)):
|
||||||
obj = datetime_to_epoch(obj)
|
obj = datetime_to_epoch(obj)
|
||||||
elif isinstance(obj, date):
|
elif isinstance(obj, date):
|
||||||
obj = (obj - EPOCH.date()).total_seconds() * 1000
|
obj = (obj - EPOCH.date()).total_seconds() * 1000
|
||||||
|
Loading…
Reference in New Issue
Block a user