Skip to content

Commit 8170283

Browse files
authored
Merge branch 'main' into bug/fix-dataset-empty-table
2 parents f8ebab2 + 9237053 commit 8170283

37 files changed

+2128
-1741
lines changed

.bumpversion.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.bumpversion]
2-
current_version = "3.9.2b1"
2+
current_version = "3.10.0"
33
commit = false
44
tag = false
55
tag_name = "{new_version}"

README.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,27 @@ FROM "sampleDB"."sampleTable" ORDER BY time DESC LIMIT 3
9494
## At scale
9595
AWS SDK for pandas can also run your workflows at scale by leveraging [Modin](https://modin.readthedocs.io/en/stable/) and [Ray](https://www.ray.io/). Both projects aim to speed up data workloads by distributing processing over a cluster of workers.
9696

97-
Read our [docs](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/scale.html) or head to our latest [tutorials](https://github.com/aws/aws-sdk-pandas/tree/main/tutorials) to learn more.
97+
Read our [docs](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/scale.html) or head to our latest [tutorials](https://github.com/aws/aws-sdk-pandas/tree/main/tutorials) to learn more.
9898

9999
> ⚠️ **Ray is currently not available for Python 3.12. While AWS SDK for pandas supports Python 3.12, it cannot be used at scale.**
100100
101101
## [Read The Docs](https://aws-sdk-pandas.readthedocs.io/)
102102

103-
- [**What is AWS SDK for pandas?**](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/about.html)
104-
- [**Install**](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html)
105-
- [PyPi (pip)](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#pypi-pip)
106-
- [Conda](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#conda)
107-
- [AWS Lambda Layer](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#aws-lambda-layer)
108-
- [AWS Glue Python Shell Jobs](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#aws-glue-python-shell-jobs)
109-
- [AWS Glue PySpark Jobs](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#aws-glue-pyspark-jobs)
110-
- [Amazon SageMaker Notebook](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#amazon-sagemaker-notebook)
111-
- [Amazon SageMaker Notebook Lifecycle](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#amazon-sagemaker-notebook-lifecycle)
112-
- [EMR](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#emr)
113-
- [From source](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/install.html#from-source)
114-
- [**At scale**](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/scale.html)
115-
- [Getting Started](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/scale.html#getting-started)
116-
- [Supported APIs](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/scale.html#supported-apis)
117-
- [Resources](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/scale.html#resources)
103+
- [**What is AWS SDK for pandas?**](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/about.html)
104+
- [**Install**](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html)
105+
- [PyPi (pip)](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#pypi-pip)
106+
- [Conda](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#conda)
107+
- [AWS Lambda Layer](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#aws-lambda-layer)
108+
- [AWS Glue Python Shell Jobs](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#aws-glue-python-shell-jobs)
109+
- [AWS Glue PySpark Jobs](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#aws-glue-pyspark-jobs)
110+
- [Amazon SageMaker Notebook](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#amazon-sagemaker-notebook)
111+
- [Amazon SageMaker Notebook Lifecycle](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#amazon-sagemaker-notebook-lifecycle)
112+
- [EMR](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#emr)
113+
- [From source](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/install.html#from-source)
114+
- [**At scale**](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/scale.html)
115+
- [Getting Started](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/scale.html#getting-started)
116+
- [Supported APIs](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/scale.html#supported-apis)
117+
- [Resources](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/scale.html#resources)
118118
- [**Tutorials**](https://github.com/aws/aws-sdk-pandas/tree/main/tutorials)
119119
- [001 - Introduction](https://github.com/aws/aws-sdk-pandas/blob/main/tutorials/001%20-%20Introduction.ipynb)
120120
- [002 - Sessions](https://github.com/aws/aws-sdk-pandas/blob/main/tutorials/002%20-%20Sessions.ipynb)
@@ -155,30 +155,30 @@ Read our [docs](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/scale.html) or
155155
- [039 - Athena Iceberg](https://github.com/aws/aws-sdk-pandas/blob/main/tutorials/039%20-%20Athena%20Iceberg.ipynb)
156156
- [040 - EMR Serverless](https://github.com/aws/aws-sdk-pandas/blob/main/tutorials/040%20-%20EMR%20Serverless.ipynb)
157157
- [041 - Apache Spark on Amazon Athena](https://github.com/aws/aws-sdk-pandas/blob/main/tutorials/041%20-%20Apache%20Spark%20on%20Amazon%20Athena.ipynb)
158-
- [**API Reference**](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html)
159-
- [Amazon S3](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-s3)
160-
- [AWS Glue Catalog](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#aws-glue-catalog)
161-
- [Amazon Athena](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-athena)
162-
- [Amazon Redshift](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-redshift)
163-
- [PostgreSQL](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#postgresql)
164-
- [MySQL](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#mysql)
165-
- [SQL Server](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#sqlserver)
166-
- [Oracle](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#oracle)
167-
- [Data API Redshift](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#data-api-redshift)
168-
- [Data API RDS](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#data-api-rds)
169-
- [OpenSearch](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#opensearch)
170-
- [AWS Glue Data Quality](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#aws-glue-data-quality)
171-
- [Amazon Neptune](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-neptune)
172-
- [DynamoDB](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#dynamodb)
173-
- [Amazon Timestream](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-timestream)
174-
- [Amazon EMR](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-emr)
175-
- [Amazon CloudWatch Logs](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-cloudwatch-logs)
176-
- [Amazon Chime](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-chime)
177-
- [Amazon QuickSight](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#amazon-quicksight)
178-
- [AWS STS](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#aws-sts)
179-
- [AWS Secrets Manager](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#aws-secrets-manager)
180-
- [Global Configurations](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#global-configurations)
181-
- [Distributed - Ray](https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/api.html#distributed-ray)
158+
- [**API Reference**](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html)
159+
- [Amazon S3](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-s3)
160+
- [AWS Glue Catalog](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#aws-glue-catalog)
161+
- [Amazon Athena](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-athena)
162+
- [Amazon Redshift](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-redshift)
163+
- [PostgreSQL](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#postgresql)
164+
- [MySQL](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#mysql)
165+
- [SQL Server](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#sqlserver)
166+
- [Oracle](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#oracle)
167+
- [Data API Redshift](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#data-api-redshift)
168+
- [Data API RDS](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#data-api-rds)
169+
- [OpenSearch](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#opensearch)
170+
- [AWS Glue Data Quality](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#aws-glue-data-quality)
171+
- [Amazon Neptune](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-neptune)
172+
- [DynamoDB](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#dynamodb)
173+
- [Amazon Timestream](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-timestream)
174+
- [Amazon EMR](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-emr)
175+
- [Amazon CloudWatch Logs](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-cloudwatch-logs)
176+
- [Amazon Chime](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-chime)
177+
- [Amazon QuickSight](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#amazon-quicksight)
178+
- [AWS STS](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#aws-sts)
179+
- [AWS Secrets Manager](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#aws-secrets-manager)
180+
- [Global Configurations](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#global-configurations)
181+
- [Distributed - Ray](https://aws-sdk-pandas.readthedocs.io/en/3.10.0/api.html#distributed-ray)
182182
- [**License**](https://github.com/aws/aws-sdk-pandas/blob/main/LICENSE.txt)
183183
- [**Contributing**](https://github.com/aws/aws-sdk-pandas/blob/main/CONTRIBUTING.md)
184184

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9.2b1
1+
3.10.0

awswrangler/__metadata__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
__title__: str = "awswrangler"
99
__description__: str = "Pandas on AWS."
10-
__version__: str = "3.9.2b1"
10+
__version__: str = "3.10.0"
1111
__license__: str = "Apache License 2.0"

awswrangler/_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ def _apply_type(name: str, value: Any, dtype: type[_ConfigValueType], nullable:
224224
raise exceptions.InvalidArgumentValue(
225225
f"{name} configuration does not accept a null value. Please pass {dtype}."
226226
)
227+
# Handle case where string is empty, "False" or "0". Anything else is True
228+
if isinstance(value, str) and dtype is bool:
229+
return value.lower() not in ("false", "0", "")
227230
try:
228231
return dtype(value) if isinstance(value, dtype) is False else value
229232
except ValueError as ex:

awswrangler/_data_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ def pyarrow2postgresql( # noqa: PLR0911
213213
return pyarrow2postgresql(dtype=dtype.value_type, string_type=string_type)
214214
if pa.types.is_binary(dtype):
215215
return "BYTEA"
216+
if pa.types.is_list(dtype):
217+
return pyarrow2postgresql(dtype=dtype.value_type, string_type=string_type) + "[]"
216218
raise exceptions.UnsupportedType(f"Unsupported PostgreSQL type: {dtype}")
217219

218220

awswrangler/_databases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ def generate_placeholder_parameter_pairs(
359359
"""Extract Placeholder and Parameter pairs."""
360360

361361
def convert_value_to_native_python_type(value: Any) -> Any:
362+
if isinstance(value, list):
363+
return value
362364
if pd.isna(value):
363365
return None
364366
if hasattr(value, "to_pydatetime"):

awswrangler/athena/_cache.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import re
88
import threading
99
from heapq import heappop, heappush
10-
from typing import TYPE_CHECKING, Any, Match, NamedTuple
10+
from typing import TYPE_CHECKING, Match, NamedTuple
1111

1212
import boto3
1313

@@ -23,23 +23,23 @@ class _CacheInfo(NamedTuple):
2323
has_valid_cache: bool
2424
file_format: str | None = None
2525
query_execution_id: str | None = None
26-
query_execution_payload: dict[str, Any] | None = None
26+
query_execution_payload: "QueryExecutionTypeDef" | None = None
2727

2828

2929
class _LocalMetadataCacheManager:
3030
def __init__(self) -> None:
3131
self._lock: threading.Lock = threading.Lock()
32-
self._cache: dict[str, Any] = {}
32+
self._cache: dict[str, "QueryExecutionTypeDef"] = {}
3333
self._pqueue: list[tuple[datetime.datetime, str]] = []
3434
self._max_cache_size = 100
3535

36-
def update_cache(self, items: list[dict[str, Any]]) -> None:
36+
def update_cache(self, items: list["QueryExecutionTypeDef"]) -> None:
3737
"""
3838
Update the local metadata cache with new query metadata.
3939
4040
Parameters
4141
----------
42-
items : List[Dict[str, Any]]
42+
items
4343
List of query execution metadata which is returned by boto3 `batch_get_query_execution()`.
4444
"""
4545
with self._lock:
@@ -62,18 +62,17 @@ def update_cache(self, items: list[dict[str, Any]]) -> None:
6262
heappush(self._pqueue, (item["Status"]["SubmissionDateTime"], item["QueryExecutionId"]))
6363
self._cache[item["QueryExecutionId"]] = item
6464

65-
def sorted_successful_generator(self) -> list[dict[str, Any]]:
65+
def sorted_successful_generator(self) -> list["QueryExecutionTypeDef"]:
6666
"""
6767
Sorts the entries in the local cache based on query Completion DateTime.
6868
6969
This is useful to guarantee LRU caching rules.
7070
7171
Returns
7272
-------
73-
List[Dict[str, Any]]
7473
Returns successful DDL and DML queries sorted by query completion time.
7574
"""
76-
filtered: list[dict[str, Any]] = []
75+
filtered: list["QueryExecutionTypeDef"] = []
7776
for query in self._cache.values():
7877
if (query["Status"].get("State") == "SUCCEEDED") and (query.get("StatementType") in ["DDL", "DML"]):
7978
filtered.append(query)
@@ -115,9 +114,7 @@ def _compare_query_string(sql: str, other: str) -> bool:
115114
comparison_query = _prepare_query_string_for_comparison(query_string=other)
116115
_logger.debug("sql: %s", sql)
117116
_logger.debug("comparison_query: %s", comparison_query)
118-
if sql == comparison_query:
119-
return True
120-
return False
117+
return sql == comparison_query
121118

122119

123120
def _prepare_query_string_for_comparison(query_string: str) -> str:
@@ -135,7 +132,7 @@ def _get_last_query_infos(
135132
max_remote_cache_entries: int,
136133
boto3_session: boto3.Session | None = None,
137134
workgroup: str | None = None,
138-
) -> list[dict[str, Any]]:
135+
) -> list["QueryExecutionTypeDef"]:
139136
"""Return an iterator of `query_execution_info`s run by the workgroup in Athena."""
140137
client_athena = _utils.client(service_name="athena", session=boto3_session)
141138
page_size = 50
@@ -160,7 +157,7 @@ def _get_last_query_infos(
160157
QueryExecutionIds=uncached_ids[i : i + page_size],
161158
).get("QueryExecutions")
162159
)
163-
_cache_manager.update_cache(new_execution_data) # type: ignore[arg-type]
160+
_cache_manager.update_cache(new_execution_data)
164161
return _cache_manager.sorted_successful_generator()
165162

166163

awswrangler/athena/_read.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -793,11 +793,11 @@ def read_sql_query(
793793
794794
**Related tutorial:**
795795
796-
- `Amazon Athena <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
796+
- `Amazon Athena <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
797797
tutorials/006%20-%20Amazon%20Athena.html>`_
798-
- `Athena Cache <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
798+
- `Athena Cache <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
799799
tutorials/019%20-%20Athena%20Cache.html>`_
800-
- `Global Configurations <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
800+
- `Global Configurations <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
801801
tutorials/021%20-%20Global%20Configurations.html>`_
802802
803803
**There are three approaches available through ctas_approach and unload_approach parameters:**
@@ -861,7 +861,7 @@ def read_sql_query(
861861
/athena.html#Athena.Client.get_query_execution>`_ .
862862
863863
For a practical example check out the
864-
`related tutorial <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
864+
`related tutorial <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
865865
tutorials/024%20-%20Athena%20Query%20Metadata.html>`_!
866866
867867
@@ -1045,7 +1045,10 @@ def read_sql_query(
10451045
# Substitute query parameters if applicable
10461046
sql, execution_params = _apply_formatter(sql, params, paramstyle)
10471047

1048-
if not client_request_token:
1048+
if not client_request_token and paramstyle != "qmark":
1049+
# For paramstyle=="qmark", we will need to use Athena's caching option.
1050+
# The issue is that when describing an Athena execution, the API does not return
1051+
# the parameters that were used.
10491052
cache_info: _CacheInfo = _check_for_cached_results(
10501053
sql=sql,
10511054
boto3_session=boto3_session,
@@ -1137,11 +1140,11 @@ def read_sql_table(
11371140
11381141
**Related tutorial:**
11391142
1140-
- `Amazon Athena <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
1143+
- `Amazon Athena <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
11411144
tutorials/006%20-%20Amazon%20Athena.html>`_
1142-
- `Athena Cache <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
1145+
- `Athena Cache <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
11431146
tutorials/019%20-%20Athena%20Cache.html>`_
1144-
- `Global Configurations <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
1147+
- `Global Configurations <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
11451148
tutorials/021%20-%20Global%20Configurations.html>`_
11461149
11471150
**There are three approaches available through ctas_approach and unload_approach parameters:**
@@ -1205,7 +1208,7 @@ def read_sql_table(
12051208
/athena.html#Athena.Client.get_query_execution>`_ .
12061209
12071210
For a practical example check out the
1208-
`related tutorial <https://aws-sdk-pandas.readthedocs.io/en/3.9.2b1/
1211+
`related tutorial <https://aws-sdk-pandas.readthedocs.io/en/3.10.0/
12091212
tutorials/024%20-%20Athena%20Query%20Metadata.html>`_!
12101213
12111214

awswrangler/athena/_utils.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from ._cache import _cache_manager, _LocalMetadataCacheManager
3636

3737
if TYPE_CHECKING:
38+
from mypy_boto3_athena.type_defs import QueryExecutionTypeDef
3839
from mypy_boto3_glue.type_defs import ColumnOutputTypeDef
3940

4041
_QUERY_FINAL_STATES: list[str] = ["FAILED", "SUCCEEDED", "CANCELLED"]
@@ -53,7 +54,7 @@ class _QueryMetadata(NamedTuple):
5354
binaries: list[str]
5455
output_location: str | None
5556
manifest_location: str | None
56-
raw_payload: dict[str, Any]
57+
raw_payload: "QueryExecutionTypeDef"
5758

5859

5960
class _WorkGroupConfig(NamedTuple):
@@ -214,7 +215,7 @@ def _get_query_metadata(
214215
query_execution_id: str,
215216
boto3_session: boto3.Session | None = None,
216217
categories: list[str] | None = None,
217-
query_execution_payload: dict[str, Any] | None = None,
218+
query_execution_payload: "QueryExecutionTypeDef" | None = None,
218219
metadata_cache_manager: _LocalMetadataCacheManager | None = None,
219220
athena_query_wait_polling_delay: float = _QUERY_WAIT_POLLING_DELAY,
220221
execution_params: list[str] | None = None,
@@ -225,12 +226,15 @@ def _get_query_metadata(
225226
if query_execution_payload["Status"]["State"] != "SUCCEEDED":
226227
reason: str = query_execution_payload["Status"]["StateChangeReason"]
227228
raise exceptions.QueryFailed(f"Query error: {reason}")
228-
_query_execution_payload: dict[str, Any] = query_execution_payload
229+
_query_execution_payload = query_execution_payload
229230
else:
230-
_query_execution_payload = _executions.wait_query(
231-
query_execution_id=query_execution_id,
232-
boto3_session=boto3_session,
233-
athena_query_wait_polling_delay=athena_query_wait_polling_delay,
231+
_query_execution_payload = cast(
232+
"QueryExecutionTypeDef",
233+
_executions.wait_query(
234+
query_execution_id=query_execution_id,
235+
boto3_session=boto3_session,
236+
athena_query_wait_polling_delay=athena_query_wait_polling_delay,
237+
),
234238
)
235239
cols_types: dict[str, str] = get_query_columns_types(
236240
query_execution_id=query_execution_id, boto3_session=boto3_session
@@ -266,8 +270,8 @@ def _get_query_metadata(
266270
if "ResultConfiguration" in _query_execution_payload:
267271
output_location = _query_execution_payload["ResultConfiguration"].get("OutputLocation")
268272

269-
athena_statistics: dict[str, int | str] = _query_execution_payload.get("Statistics", {})
270-
manifest_location: str | None = str(athena_statistics.get("DataManifestLocation"))
273+
athena_statistics = _query_execution_payload.get("Statistics", {})
274+
manifest_location: str | None = athena_statistics.get("DataManifestLocation")
271275

272276
if metadata_cache_manager is not None and query_execution_id not in metadata_cache_manager:
273277
metadata_cache_manager.update_cache(items=[_query_execution_payload])

0 commit comments

Comments
 (0)