mirror of https://github.com/apache/superset.git
fix: enable pylint rules in db_engine_specs module (#10998)
* Athena.py: cretaed variable for too long line, removed disabled pylint rule. * Enabled `line-too-long` in `drill.py`. Added variable for too long string. * Reformatted hana.py: - changed return statement into two lines to keep line lenght limit * Enabling pylint rule in hive.py: - `no-name-in-module` for pyhive in several places - `line-too-long` and adding new lines - `unused-import` is not invalid anymore * Enabled `line-too-long` in `kylin.py`. Added variable for too long string. * Enabled `unused_import` in `base.py` from db_engine_specs module. * Enabled `unused_import` in `bigquery.py` from db_engine_specs module. * Enabled `unused_import` in `druid.py` from db_engine_specs module. * fix: athena datetime string converting
This commit is contained in:
parent
e93d92e8ac
commit
a6f258747b
|
@ -47,7 +47,8 @@ class AthenaEngineSpec(BaseEngineSpec):
|
|||
if tt == utils.TemporalType.DATE:
|
||||
return f"from_iso8601_date('{dttm.date().isoformat()}')"
|
||||
if tt == utils.TemporalType.TIMESTAMP:
|
||||
return f"""from_iso8601_timestamp('{dttm.isoformat(timespec="microseconds")}')""" # pylint: disable=line-too-long
|
||||
datetime_formatted = dttm.isoformat(timespec="microseconds")
|
||||
return f"""from_iso8601_timestamp('{datetime_formatted}')"""
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -59,10 +59,8 @@ from superset.utils import core as utils
|
|||
|
||||
if TYPE_CHECKING:
|
||||
# prevent circular imports
|
||||
from superset.connectors.sqla.models import ( # pylint: disable=unused-import
|
||||
TableColumn,
|
||||
)
|
||||
from superset.models.core import Database # pylint: disable=unused-import
|
||||
from superset.connectors.sqla.models import TableColumn
|
||||
from superset.models.core import Database
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ from superset.db_engine_specs.base import BaseEngineSpec
|
|||
from superset.utils import core as utils
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# pylint: disable=unused-import
|
||||
from superset.models.core import Database # pragma: no cover
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,8 @@ class DrillEngineSpec(BaseEngineSpec):
|
|||
if tt == utils.TemporalType.DATE:
|
||||
return f"TO_DATE('{dttm.date().isoformat()}', 'yyyy-MM-dd')"
|
||||
if tt == utils.TemporalType.TIMESTAMP:
|
||||
return f"""TO_TIMESTAMP('{dttm.isoformat(sep=" ", timespec="seconds")}', 'yyyy-MM-dd HH:mm:ss')""" # pylint: disable=line-too-long
|
||||
datetime_formatted = dttm.isoformat(sep=" ", timespec="seconds")
|
||||
return f"""TO_TIMESTAMP('{datetime_formatted}', 'yyyy-MM-dd HH:mm:ss')"""
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -23,10 +23,8 @@ from superset.db_engine_specs.base import BaseEngineSpec
|
|||
from superset.utils import core as utils
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from superset.connectors.sqla.models import ( # pylint: disable=unused-import
|
||||
TableColumn,
|
||||
)
|
||||
from superset.models.core import Database # pylint: disable=unused-import
|
||||
from superset.connectors.sqla.models import TableColumn
|
||||
from superset.models.core import Database
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
|
|
@ -48,5 +48,6 @@ class HanaEngineSpec(PostgresBaseEngineSpec):
|
|||
if tt == utils.TemporalType.DATE:
|
||||
return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')"
|
||||
if tt == utils.TemporalType.TIMESTAMP:
|
||||
return f"""TO_TIMESTAMP('{dttm.isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')""" # pylint: disable=line-too-long
|
||||
return f"""TO_TIMESTAMP('{dttm
|
||||
.isoformat(timespec="microseconds")}', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')"""
|
||||
return None
|
||||
|
|
|
@ -41,7 +41,7 @@ from superset.utils import core as utils
|
|||
|
||||
if TYPE_CHECKING:
|
||||
# prevent circular imports
|
||||
from superset.models.core import Database # pylint: disable=unused-import
|
||||
from superset.models.core import Database
|
||||
|
||||
QueryStatus = utils.QueryStatus
|
||||
config = app.config
|
||||
|
@ -111,7 +111,7 @@ class HiveEngineSpec(PrestoEngineSpec):
|
|||
|
||||
@classmethod
|
||||
def patch(cls) -> None:
|
||||
from pyhive import hive # pylint: disable=no-name-in-module
|
||||
from pyhive import hive
|
||||
from TCLIService import (
|
||||
constants as patched_constants,
|
||||
TCLIService as patched_TCLIService,
|
||||
|
@ -263,7 +263,8 @@ class HiveEngineSpec(PrestoEngineSpec):
|
|||
if tt == utils.TemporalType.DATE:
|
||||
return f"CAST('{dttm.date().isoformat()}' AS DATE)"
|
||||
if tt == utils.TemporalType.TIMESTAMP:
|
||||
return f"""CAST('{dttm.isoformat(sep=" ", timespec="microseconds")}' AS TIMESTAMP)""" # pylint: disable=line-too-long
|
||||
return f"""CAST('{dttm
|
||||
.isoformat(sep=" ", timespec="microseconds")}' AS TIMESTAMP)"""
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
|
@ -325,7 +326,7 @@ class HiveEngineSpec(PrestoEngineSpec):
|
|||
cls, cursor: Any, query: Query, session: Session
|
||||
) -> None:
|
||||
"""Updates progress information"""
|
||||
from pyhive import hive # pylint: disable=no-name-in-module
|
||||
from pyhive import hive
|
||||
|
||||
unfinished_states = (
|
||||
hive.ttypes.TOperationState.INITIALIZED_STATE,
|
||||
|
|
|
@ -47,5 +47,6 @@ class KylinEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
|
|||
if tt == utils.TemporalType.DATE:
|
||||
return f"CAST('{dttm.date().isoformat()}' AS DATE)"
|
||||
if tt == utils.TemporalType.TIMESTAMP:
|
||||
return f"""CAST('{dttm.isoformat(sep=" ", timespec="seconds")}' AS TIMESTAMP)""" # pylint: disable=line-too-long
|
||||
datetime_fomatted = dttm.isoformat(sep=" ", timespec="seconds")
|
||||
return f"""CAST('{datetime_fomatted}' AS TIMESTAMP)"""
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue