mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
Add docstrings and typing to db_engine_specs and sql_parse (#8058)
* Add typing to db_engine_specs * Add more type annotations and docstrings * Add docstrings and typing to sql_parse and db_engine_specs * Refine select_star * Fix execute and add more docstrings * Revert kwargs change from execute * Remove redundant or * Align view and table getter schema types * Fix return type of latest_partition * Remove some typing from presto * Improve docstring for __extract_from_token
This commit is contained in:
@@ -15,8 +15,11 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# pylint: disable=C,R,W
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.utils import core as utils
|
||||
|
||||
@@ -38,7 +41,7 @@ class SqliteEngineSpec(BaseEngineSpec):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def epoch_to_dttm(cls):
|
||||
def epoch_to_dttm(cls) -> str:
|
||||
return "datetime({col}, 'unixepoch')"
|
||||
|
||||
@classmethod
|
||||
@@ -69,13 +72,13 @@ class SqliteEngineSpec(BaseEngineSpec):
|
||||
raise Exception(f"Unsupported datasource_type: {datasource_type}")
|
||||
|
||||
@classmethod
|
||||
def convert_dttm(cls, target_type, dttm):
|
||||
def convert_dttm(cls, target_type: str, dttm: datetime) -> str:
|
||||
iso = dttm.isoformat().replace("T", " ")
|
||||
if "." not in iso:
|
||||
iso += ".000000"
|
||||
return "'{}'".format(iso)
|
||||
|
||||
@classmethod
|
||||
def get_table_names(cls, inspector, schema):
|
||||
def get_table_names(cls, inspector: Inspector, schema: str) -> List[str]:
|
||||
"""Need to disregard the schema for Sqlite"""
|
||||
return sorted(inspector.get_table_names())
|
||||
|
||||
Reference in New Issue
Block a user