superset 时区问题Timestamp subtraction must have the same timezones or no timezones
superset綁定數(shù)據(jù)源后,切換到圖表展示時(shí)報(bào)錯(cuò):
Timestamp subtraction must have the same timezones or no timezones
File "/usr/local/lib/python3.6/site-packages/superset/utils/core.py", line 362, in datetime_to_epoch return (dttm - epoch_with_tz).total_seconds() * 1000
?
原因:
兩個(gè)時(shí)間的時(shí)區(qū)不一樣,經(jīng)輸出發(fā)現(xiàn)dttm.tzinfo屬性異常,估計(jì)會被誤判時(shí)區(qū),也無法根據(jù)dttm.tzinfo來調(diào)整0時(shí)間的時(shí)區(qū),所以可以采用折中方式重新生成一個(gè)無時(shí)區(qū)的時(shí)間對象跟0時(shí)間相減來獲得時(shí)間戳。
時(shí)間關(guān)系,實(shí)現(xiàn)方式略顯笨重,不夠優(yōu)化,考慮性能的地方建議進(jìn)一步研究徹底解決該問題。
?
?
解決方式:
/usr/local/lib/python3.6/site-packages/superset/安裝路徑中
修改utils/core.py的datetime_to_epoch方法
def datetime_to_epoch(dttm):
if dttm.tzinfo:
dt=datetime.strptime(dttm.strftime('%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S')
return (dt - EPOCH).total_seconds() * 1000
return (dttm - EPOCH).total_seconds() * 1000
?
?
總結(jié)
以上是生活随笔為你收集整理的superset 时区问题Timestamp subtraction must have the same timezones or no timezones的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle选择外键列,Oracle外键
- 下一篇: 新流程的搭建