mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(sqllab/charts): casting from timestamp[us] to timestamp[ns] would result in out of bounds timestamp (#18873)
* fix casting from timestamp[us] to timestamp[ns] would result in out of bounds timestamp from sqllab and charts
* Add unittests
* Lint changes and parameter variable rename
* Fix linting
(cherry picked from commit 8b72354654)
This commit is contained in:
committed by
Michael S. Molina
parent
9ca53b8905
commit
8becd3e080
@@ -1762,14 +1762,14 @@ def normalize_dttm_col(
|
||||
# Column is formatted as a numeric value
|
||||
unit = timestamp_format.replace("epoch_", "")
|
||||
df[DTTM_ALIAS] = pd.to_datetime(
|
||||
dttm_col, utc=False, unit=unit, origin="unix"
|
||||
dttm_col, utc=False, unit=unit, origin="unix", errors="coerce"
|
||||
)
|
||||
else:
|
||||
# Column has already been formatted as a timestamp.
|
||||
df[DTTM_ALIAS] = dttm_col.apply(pd.Timestamp)
|
||||
else:
|
||||
df[DTTM_ALIAS] = pd.to_datetime(
|
||||
df[DTTM_ALIAS], utc=False, format=timestamp_format
|
||||
df[DTTM_ALIAS], utc=False, format=timestamp_format, errors="coerce"
|
||||
)
|
||||
if offset:
|
||||
df[DTTM_ALIAS] += timedelta(hours=offset)
|
||||
|
||||
Reference in New Issue
Block a user