diff --git a/UPDATING.md b/UPDATING.md index 59b558b2895f1..a5fb797589d47 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -23,6 +23,10 @@ assists people when migrating to a new version. ## Next Version +* [7667](https://github.com/apache/incubator-superset/pull/7667): a change to +make all Unix timestamp (which by definition are in UTC) comparisons refer +to a timestamp in UTC as opposed to local time. + * [5451](https://github.com/apache/incubator-superset/pull/5451): a change which adds missing non-nullable fields to the `datasources` table. Depending on the integrity of the data, manual intervention may be required. @@ -33,7 +37,7 @@ which adds missing non-nullable fields and uniqueness constraints to the manual intervention may be required. * `fabmanager` command line is deprecated since Flask-AppBuilder 2.0.0, use the new `flask fab ` integrated with *Flask cli*. -* `SUPERSET_UPDATE_PERMS` environment variable was replaced by +* `SUPERSET_UPDATE_PERMS` environment variable was replaced by `FAB_UPDATE_PERMS` config boolean key. To disable automatic creation of permissions set `FAB_UPDATE_PERMS = False` on config. * [5453](https://github.com/apache/incubator-superset/pull/5453): a change diff --git a/superset/config.py b/superset/config.py index 7d6ca33e5f9aa..4baaf15e6303f 100644 --- a/superset/config.py +++ b/superset/config.py @@ -608,11 +608,6 @@ class CeleryConfig(object): DEFAULT_RELATIVE_START_TIME = 'today' DEFAULT_RELATIVE_END_TIME = 'today' -# Is epoch_s/epoch_ms datetime format supposed to be considered since UTC ? -# If not, it is sassumed then the epoch_s/epoch_ms is seconds since 1/1/1970 -# localtime (in the tz where the superset webserver is running) -IS_EPOCH_S_TRULY_UTC = False - # Configure which SQL validator to use for each engine SQL_VALIDATORS_BY_ENGINE = { 'presto': 'PrestoDBSQLValidator', diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 138b0e5d5cd64..c8d518d884450 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -133,13 +133,12 @@ def datasource(self): return self.table def get_time_filter(self, start_dttm, end_dttm): - is_epoch_in_utc = config.get('IS_EPOCH_S_TRULY_UTC', False) col = self.get_sqla_col(label='__time') l = [] # noqa: E741 if start_dttm: - l.append(col >= text(self.dttm_sql_literal(start_dttm, is_epoch_in_utc))) + l.append(col >= text(self.dttm_sql_literal(start_dttm))) if end_dttm: - l.append(col <= text(self.dttm_sql_literal(end_dttm, is_epoch_in_utc))) + l.append(col <= text(self.dttm_sql_literal(end_dttm))) return and_(*l) def get_timestamp_expression(self, time_grain: Optional[str]) \ @@ -173,7 +172,7 @@ def lookup_obj(lookup_column): TableColumn.column_name == lookup_column.column_name).first() return import_datasource.import_simple_obj(db.session, i_column, lookup_obj) - def dttm_sql_literal(self, dttm, is_epoch_in_utc): + def dttm_sql_literal(self, dttm): """Convert datetime object to a SQL expression string If database_expression is empty, the internal dttm @@ -186,11 +185,7 @@ def dttm_sql_literal(self, dttm, is_epoch_in_utc): if self.database_expression: return self.database_expression.format(dttm.strftime('%Y-%m-%d %H:%M:%S')) elif tf: - if is_epoch_in_utc: - seconds_since_epoch = dttm.timestamp() - else: - seconds_since_epoch = (dttm - datetime(1970, 1, 1)).total_seconds() - seconds_since_epoch = int(seconds_since_epoch) + seconds_since_epoch = int(dttm.timestamp()) if tf == 'epoch_s': return str(seconds_since_epoch) elif tf == 'epoch_ms':