Athena¶
Utilities for working with AWS Athena.
get_query_execution ¶
get_query_execution(query_execution_id)
Get the status and details of an Athena query execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_execution_id
|
str
|
The unique identifier of the query execution. |
required |
Raises:
| Type | Description |
|---|---|
AWSError
|
If the query execution cannot be retrieved. |
Returns:
| Type | Description |
|---|---|
GetQueryExecutionOutputTypeDef
|
The query execution details including status and results location. |
Source code in src/aibs_informatics_aws_utils/athena.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
query_waiter ¶
query_waiter(query_execution_id, timeout=60)
Wait for an Athena query to complete.
Polls the query execution status until it reaches a terminal state (SUCCEEDED, FAILED, CANCELLED) or times out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_execution_id
|
str
|
The unique identifier of the query execution. |
required |
timeout
|
int
|
Maximum time to wait in seconds. Defaults to 60. |
60
|
Returns:
| Type | Description |
|---|---|
Tuple[ATHENA_QUERY_WAITER_STATUS, QueryExecutionStatusTypeDef]
|
A tuple of (status, status_details) where status is one of SUCCEEDED, FAILED, CANCELLED, or TIMEOUT. |
Source code in src/aibs_informatics_aws_utils/athena.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
start_query_execution ¶
start_query_execution(
query_string,
work_group=None,
execution_parameters=None,
**kwargs
)
Start an Athena query execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query_string
|
str
|
The SQL query string to execute. |
required |
work_group
|
Optional[str]
|
The name of the workgroup to execute the query in. |
None
|
execution_parameters
|
Optional[List[str]]
|
Optional list of query execution parameters. |
None
|
**kwargs
|
Unpack[StartQueryExecutionInputTypeDef]
|
Additional arguments passed to the Athena start_query_execution API. |
{}
|
Raises:
| Type | Description |
|---|---|
AWSError
|
If the query execution fails to start. |
Returns:
| Type | Description |
|---|---|
StartQueryExecutionOutputTypeDef
|
The start query execution response containing the QueryExecutionId. |
Source code in src/aibs_informatics_aws_utils/athena.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |