Superset 稀奇古怪的bug

1、filterbox 及 native filter 等组件里面,日期筛选器下拉框,显示的不是日期格式,而是时间戳格式,如:

解决方法:

修改superset\utils\core.py 里面的json_int_dttm_ser函数,注释掉obj = (obj - EPOCH.date()).total_seconds() * 1000,更改为 obj = obj.strftime("%Y/%m/%d")

def json_int_dttm_ser(obj: Any) -> float:
    """json serializer that deals with dates"""
    val = base_json_conv(obj)
    if val is not None:
        return val
    if isinstance(obj, (datetime, pd.Timestamp)):
        obj = datetime_to_epoch(obj)
    elif isinstance(obj, date):
        #obj = (obj - EPOCH.date()).total_seconds() * 1000
        obj = obj.strftime("%Y/%m/%d")
    else:
        raise TypeError("Unserializable object {} of type {}".format(obj, type(obj)))
    return obj

 

posted @ 2021-08-26 14:56  数据行者  阅读(801)  评论(0编辑  收藏  举报