mirror of
https://github.com/apache/superset.git
synced 2026-04-22 01:24:43 +00:00
Make timestamp expression native SQLAlchemy element (#7131)
* Add native sqla component for time expressions * Add unit tests and remove old tests * Remove redundant _grains_dict method * Clarify time_grain logic * Add docstrings and typing * Fix flake8 errors * Add missing typings * Rename to TimestampExpression * Remove redundant tests * Fix broken reference to db.database_name due to refactor
This commit is contained in:
@@ -1029,21 +1029,13 @@ class Database(Model, AuditMixinNullable, ImportMixin):
|
||||
"""Defines time granularity database-specific expressions.
|
||||
|
||||
The idea here is to make it easy for users to change the time grain
|
||||
form a datetime (maybe the source grain is arbitrary timestamps, daily
|
||||
from a datetime (maybe the source grain is arbitrary timestamps, daily
|
||||
or 5 minutes increments) to another, "truncated" datetime. Since
|
||||
each database has slightly different but similar datetime functions,
|
||||
this allows a mapping between database engines and actual functions.
|
||||
"""
|
||||
return self.db_engine_spec.get_time_grains()
|
||||
|
||||
def grains_dict(self):
|
||||
"""Allowing to lookup grain by either label or duration
|
||||
|
||||
For backward compatibility"""
|
||||
d = {grain.duration: grain for grain in self.grains()}
|
||||
d.update({grain.label: grain for grain in self.grains()})
|
||||
return d
|
||||
|
||||
def get_extra(self):
|
||||
extra = {}
|
||||
if self.extra:
|
||||
|
||||
Reference in New Issue
Block a user