semantics
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# #region SupersetSqlLabExecutor [C:4] [TYPE Module] [SEMANTICS translate, superset, sqllab, execute]
|
||||
# #region SupersetSqlLabExecutor [C:4] [TYPE Module] [SEMANTICS translate, superset, sqllab, execute, query]
|
||||
# @BRIEF Submit SQL to Superset SQL Lab API and poll execution status.
|
||||
# @LAYER: Infra
|
||||
# @RELATION DEPENDS_ON -> [SupersetClient]
|
||||
@@ -33,7 +33,7 @@ class SupersetSqlLabExecutor:
|
||||
self._client: Optional[SupersetClient] = None
|
||||
self._database_id: Optional[int] = None
|
||||
|
||||
# [DEF:_get_client:Function]
|
||||
# region _get_client [TYPE Function]
|
||||
# @PURPOSE: Lazy-initialize SupersetClient for the configured environment.
|
||||
# @PRE: env_id must correspond to a valid environment config.
|
||||
# @POST: Returns authenticated SupersetClient.
|
||||
@@ -50,9 +50,9 @@ class SupersetSqlLabExecutor:
|
||||
|
||||
self._client = SupersetClient(env_config)
|
||||
return self._client
|
||||
# [/DEF:_get_client:Function]
|
||||
# endregion _get_client
|
||||
|
||||
# [DEF:resolve_database_id:Function]
|
||||
# region resolve_database_id [TYPE Function]
|
||||
# @PURPOSE: Resolve the target database ID from the environment.
|
||||
# @PRE: database_name or database_id should be known.
|
||||
# @POST: Returns database_id integer or raises ValueError.
|
||||
@@ -86,9 +86,9 @@ class SupersetSqlLabExecutor:
|
||||
"database_id": self._database_id,
|
||||
})
|
||||
return self._database_id
|
||||
# [/DEF:resolve_database_id:Function]
|
||||
# endregion resolve_database_id
|
||||
|
||||
# [DEF:execute_sql:Function]
|
||||
# region execute_sql [TYPE Function]
|
||||
# @PURPOSE: Submit SQL to Superset SQL Lab and return execution tracking info.
|
||||
# @PRE: sql is valid SQL string. database_id is a valid Superset DB ID.
|
||||
# @POST: Returns execution result dict with query_id and status.
|
||||
@@ -146,9 +146,9 @@ class SupersetSqlLabExecutor:
|
||||
"raw_response": result,
|
||||
"database_id": db_id,
|
||||
}
|
||||
# [/DEF:execute_sql:Function]
|
||||
# endregion execute_sql
|
||||
|
||||
# [DEF:poll_execution_status:Function]
|
||||
# region poll_execution_status [TYPE Function]
|
||||
# @PURPOSE: Poll Superset for SQL execution status until completion or timeout.
|
||||
# @PRE: query_id is a valid Superset query ID.
|
||||
# @POST: Returns final execution status dict.
|
||||
@@ -237,9 +237,9 @@ class SupersetSqlLabExecutor:
|
||||
"error_message": f"Polling timed out after {max_polls} attempts",
|
||||
"results": None,
|
||||
}
|
||||
# [/DEF:poll_execution_status:Function]
|
||||
# endregion poll_execution_status
|
||||
|
||||
# [DEF:execute_and_poll:Function]
|
||||
# region execute_and_poll [TYPE Function]
|
||||
# @PURPOSE: Execute SQL and wait for completion. One-shot convenience method.
|
||||
# @PRE: sql is valid SQL.
|
||||
# @POST: Returns final execution result.
|
||||
@@ -274,9 +274,9 @@ class SupersetSqlLabExecutor:
|
||||
max_polls=max_polls,
|
||||
poll_interval_seconds=poll_interval_seconds,
|
||||
)
|
||||
# [/DEF:execute_and_poll:Function]
|
||||
# endregion execute_and_poll
|
||||
|
||||
# [DEF:get_query_results:Function]
|
||||
# region get_query_results [TYPE Function]
|
||||
# @PURPOSE: Fetch the results of a completed query.
|
||||
# @PRE: query_id is a valid Superset query ID.
|
||||
# @POST: Returns query results if available.
|
||||
@@ -306,7 +306,7 @@ class SupersetSqlLabExecutor:
|
||||
"error_message": str(e),
|
||||
"results": None,
|
||||
}
|
||||
# [/DEF:get_query_results:Function]
|
||||
# endregion get_query_results
|
||||
|
||||
|
||||
# #endregion SupersetSqlLabExecutor
|
||||
|
||||
Reference in New Issue
Block a user