Skip to content

Commit

Permalink
style, (T1, T2) ==> Tuple[T1, T2]
Browse files Browse the repository at this point in the history
  • Loading branch information
zqWu committed Mar 10, 2023
1 parent fbbb55f commit e3550f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions dbt/adapters/flink/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _read_session_handle(cls, credentials: FlinkCredentials) -> Optional[SqlGate
)

if (
datetime.now() - session_timestamp
datetime.now() - session_timestamp
).seconds > credentials.session_idle_timeout_s:
logger.info("Stored session has timeout.")
return None
Expand Down Expand Up @@ -182,7 +182,7 @@ def show_catalogs(self) -> List[str]:
def show_databases(self, catalog: str) -> List[str]:
return SchemaOperation.show_databases(self.current_session(), catalog)

def show_relations(self, catalog: str, database: str) -> (List[str], List[str]):
def show_relations(self, catalog: str, database: str) -> Tuple[List[str], List[str]]:
tables, views = SchemaOperation.show_relations(self.current_session(), catalog, database)
return tables, views

Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/flink/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_columns_in_relation(self, relation: BaseRelation) -> List[BaseColumn]:
def is_cancelable(cls) -> bool:
return False # TODO

def list_relations_without_caching(self, schema_relation: BaseRelation) -> List[BaseRelation]:
def list_relations_without_caching(self, schema_relation: BaseRelation) -> List[FlinkRelation]:
database = schema_relation.path.database
if not database:
raise RuntimeError("database(flink catalog) should not be empty")
Expand Down
21 changes: 8 additions & 13 deletions flink/sqlgateway/schema_operations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from typing import List
from typing import List, Tuple

from flink.sqlgateway.operation import SqlGatewayOperation
from flink.sqlgateway.result_parser import SqlGatewayResult
Expand All @@ -15,6 +15,7 @@
sql_show_databases = "show databases"
sql_show_current_database = "show current database"
sql_show_tables = "show tables"
sql_show_views = "show views"

pull_interval_s = 0.1

Expand Down Expand Up @@ -107,12 +108,10 @@ def show_databases(session: SqlGatewaySession, catalog: str) -> List[str]:
return dbs

@staticmethod
def show_relations(session, catalog: str, database: str) -> (List[str], List[str]):
"""
note: for hive catalog, show tables also returns views
views = show views in catalog.database
tables = show tables in catalog.database - views
"""
def show_relations(session, catalog: str, database: str) -> Tuple[List[str], List[str]]:
# note: for hive catalog, show tables also returns views
# views = show views in catalog.database
# tables = show tables in catalog.database - views
views = SchemaOperation.show_views(session, catalog, database)

if catalog is None:
Expand All @@ -136,12 +135,8 @@ def show_tables(session: SqlGatewaySession, catalog: str = None, database: str =

@staticmethod
def show_views(session: SqlGatewaySession, catalog: str = None, database: str = None) -> List[str]:
"""
NO such sql
show views in|from catalog.database
"""
sql = "show views"
return SchemaOperation.show_xxx(session, sql)
# NO such sql: show views in|from catalog.database
return SchemaOperation.show_xxx(session, sql_show_views)

@staticmethod
def show_xxx(session: SqlGatewaySession, sql: str) -> List[str]:
Expand Down

0 comments on commit e3550f9

Please sign in to comment.