Allow user to customize query cost estimate (#8470)

* Allow user to customize query estimate

* Add docs; run black

* Update docs with types
This commit is contained in:
Beto Dealmeida
2019-11-04 11:08:00 -08:00
committed by GitHub
parent 9a29116d6b
commit 338a2b1a51
4 changed files with 75 additions and 8 deletions

View File

@@ -674,7 +674,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
@classmethod
def estimate_statement_cost(
cls, statement: str, database, cursor, user_name: str
) -> Dict[str, str]:
) -> Dict[str, Any]:
"""
Generate a SQL query that estimates the cost of a given statement.
@@ -682,6 +682,19 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
:param database: Database instance
:param cursor: Cursor instance
:param username: Effective username
:return: Dictionary with different costs
"""
raise Exception("Database does not support cost estimation")
@classmethod
def query_cost_formatter(
cls, raw_cost: List[Dict[str, Any]]
) -> List[Dict[str, str]]:
"""
Format cost estimate.
:param raw_cost: Raw estimate from `estimate_query_cost`
:return: Human readable cost estimate
"""
raise Exception("Database does not support cost estimation")