mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[BugFix]: Creating a PostgresBaseEngineSpec so changes to the Postgre… (#4224)
* [BugFix]: Creating a PostgresBaseEngineSpec so changes to the PostgresEngineSpec don't affect every subclass * Empty engine for abstract Engine
This commit is contained in:
parent
d41418eaa0
commit
a9e1e685ba
@ -280,8 +280,10 @@ class BaseEngineSpec(object):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class PostgresEngineSpec(BaseEngineSpec):
|
class PostgresBaseEngineSpec(BaseEngineSpec):
|
||||||
engine = 'postgresql'
|
""" Abstract class for Postgres 'like' databases """
|
||||||
|
|
||||||
|
engine = ''
|
||||||
|
|
||||||
time_grains = (
|
time_grains = (
|
||||||
Grain('Time Column', _('Time Column'), '{col}'),
|
Grain('Time Column', _('Time Column'), '{col}'),
|
||||||
@ -311,6 +313,10 @@ class PostgresEngineSpec(BaseEngineSpec):
|
|||||||
def convert_dttm(cls, target_type, dttm):
|
def convert_dttm(cls, target_type, dttm):
|
||||||
return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S'))
|
return "'{}'".format(dttm.strftime('%Y-%m-%d %H:%M:%S'))
|
||||||
|
|
||||||
|
|
||||||
|
class PostgresEngineSpec(PostgresBaseEngineSpec):
|
||||||
|
engine = 'postgresql'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_table_names(cls, schema, inspector):
|
def get_table_names(cls, schema, inspector):
|
||||||
"""Need to consider foreign tables for PostgreSQL"""
|
"""Need to consider foreign tables for PostgreSQL"""
|
||||||
@ -319,6 +325,35 @@ class PostgresEngineSpec(BaseEngineSpec):
|
|||||||
return sorted(tables)
|
return sorted(tables)
|
||||||
|
|
||||||
|
|
||||||
|
class VerticaEngineSpec(PostgresBaseEngineSpec):
|
||||||
|
engine = 'vertica'
|
||||||
|
|
||||||
|
|
||||||
|
class RedshiftEngineSpec(PostgresBaseEngineSpec):
|
||||||
|
engine = 'redshift'
|
||||||
|
|
||||||
|
|
||||||
|
class OracleEngineSpec(PostgresBaseEngineSpec):
|
||||||
|
engine = 'oracle'
|
||||||
|
|
||||||
|
time_grains = (
|
||||||
|
Grain('Time Column', _('Time Column'), '{col}'),
|
||||||
|
Grain('minute', _('minute'), "TRUNC(TO_DATE({col}), 'MI')"),
|
||||||
|
Grain('hour', _('hour'), "TRUNC(TO_DATE({col}), 'HH')"),
|
||||||
|
Grain('day', _('day'), "TRUNC(TO_DATE({col}), 'DDD')"),
|
||||||
|
Grain('week', _('week'), "TRUNC(TO_DATE({col}), 'WW')"),
|
||||||
|
Grain('month', _('month'), "TRUNC(TO_DATE({col}), 'MONTH')"),
|
||||||
|
Grain('quarter', _('quarter'), "TRUNC(TO_DATE({col}), 'Q')"),
|
||||||
|
Grain('year', _('year'), "TRUNC(TO_DATE({col}), 'YEAR')"),
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def convert_dttm(cls, target_type, dttm):
|
||||||
|
return (
|
||||||
|
"""TO_TIMESTAMP('{}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""
|
||||||
|
).format(dttm.isoformat())
|
||||||
|
|
||||||
|
|
||||||
class Db2EngineSpec(BaseEngineSpec):
|
class Db2EngineSpec(BaseEngineSpec):
|
||||||
engine = 'ibm_db_sa'
|
engine = 'ibm_db_sa'
|
||||||
time_grains = (
|
time_grains = (
|
||||||
@ -1046,42 +1081,6 @@ class MssqlEngineSpec(BaseEngineSpec):
|
|||||||
return "CONVERT(DATETIME, '{}', 126)".format(dttm.isoformat())
|
return "CONVERT(DATETIME, '{}', 126)".format(dttm.isoformat())
|
||||||
|
|
||||||
|
|
||||||
class RedshiftEngineSpec(PostgresEngineSpec):
|
|
||||||
engine = 'redshift'
|
|
||||||
|
|
||||||
|
|
||||||
class OracleEngineSpec(PostgresEngineSpec):
|
|
||||||
engine = 'oracle'
|
|
||||||
|
|
||||||
time_grains = (
|
|
||||||
Grain('Time Column', _('Time Column'), '{col}'),
|
|
||||||
Grain('minute', _('minute'),
|
|
||||||
"TRUNC(TO_DATE({col}), 'MI')"),
|
|
||||||
Grain('hour', _('hour'),
|
|
||||||
"TRUNC(TO_DATE({col}), 'HH')"),
|
|
||||||
Grain('day', _('day'),
|
|
||||||
"TRUNC(TO_DATE({col}), 'DDD')"),
|
|
||||||
Grain('week', _('week'),
|
|
||||||
"TRUNC(TO_DATE({col}), 'WW')"),
|
|
||||||
Grain('month', _('month'),
|
|
||||||
"TRUNC(TO_DATE({col}), 'MONTH')"),
|
|
||||||
Grain('quarter', _('quarter'),
|
|
||||||
"TRUNC(TO_DATE({col}), 'Q')"),
|
|
||||||
Grain('year', _('year'),
|
|
||||||
"TRUNC(TO_DATE({col}), 'YEAR')"),
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def convert_dttm(cls, target_type, dttm):
|
|
||||||
return (
|
|
||||||
"""TO_TIMESTAMP('{}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""
|
|
||||||
).format(dttm.isoformat())
|
|
||||||
|
|
||||||
|
|
||||||
class VerticaEngineSpec(PostgresEngineSpec):
|
|
||||||
engine = 'vertica'
|
|
||||||
|
|
||||||
|
|
||||||
class AthenaEngineSpec(BaseEngineSpec):
|
class AthenaEngineSpec(BaseEngineSpec):
|
||||||
engine = 'awsathena'
|
engine = 'awsathena'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user