@@ -320,7 +320,6 @@ def _resolve_query_without_cache_ctas(
320320 boto3_session : boto3 .Session | None ,
321321 pyarrow_additional_kwargs : dict [str , Any ] | None = None ,
322322 execution_params : list [str ] | None = None ,
323- result_reuse_configuration : dict [str , Any ] | None = None ,
324323 dtype_backend : Literal ["numpy_nullable" , "pyarrow" ] = "numpy_nullable" ,
325324) -> pd .DataFrame | Iterator [pd .DataFrame ]:
326325 ctas_query_info : dict [str , str | _QueryMetadata ] = create_ctas_table (
@@ -340,7 +339,6 @@ def _resolve_query_without_cache_ctas(
340339 boto3_session = boto3_session ,
341340 params = execution_params ,
342341 paramstyle = "qmark" ,
343- result_reuse_configuration = result_reuse_configuration ,
344342 )
345343 fully_qualified_name : str = f'"{ ctas_query_info ["ctas_database" ]} "."{ ctas_query_info ["ctas_table" ]} "'
346344 ctas_query_metadata = cast (_QueryMetadata , ctas_query_info ["ctas_query_metadata" ])
@@ -380,7 +378,6 @@ def _resolve_query_without_cache_unload(
380378 boto3_session : boto3 .Session | None ,
381379 pyarrow_additional_kwargs : dict [str , Any ] | None = None ,
382380 execution_params : list [str ] | None = None ,
383- result_reuse_configuration : dict [str , Any ] | None = None ,
384381 dtype_backend : Literal ["numpy_nullable" , "pyarrow" ] = "numpy_nullable" ,
385382) -> pd .DataFrame | Iterator [pd .DataFrame ]:
386383 query_metadata = _unload (
@@ -398,7 +395,6 @@ def _resolve_query_without_cache_unload(
398395 data_source = data_source ,
399396 athena_query_wait_polling_delay = athena_query_wait_polling_delay ,
400397 execution_params = execution_params ,
401- result_reuse_configuration = result_reuse_configuration ,
402398 )
403399 if file_format == "PARQUET" :
404400 return _fetch_parquet_result (
@@ -533,7 +529,6 @@ def _resolve_query_without_cache( # noqa: PLR0913
533529 boto3_session = boto3_session ,
534530 pyarrow_additional_kwargs = pyarrow_additional_kwargs ,
535531 execution_params = execution_params ,
536- result_reuse_configuration = result_reuse_configuration ,
537532 dtype_backend = dtype_backend ,
538533 )
539534 finally :
@@ -562,7 +557,6 @@ def _resolve_query_without_cache( # noqa: PLR0913
562557 boto3_session = boto3_session ,
563558 pyarrow_additional_kwargs = pyarrow_additional_kwargs ,
564559 execution_params = execution_params ,
565- result_reuse_configuration = result_reuse_configuration ,
566560 dtype_backend = dtype_backend ,
567561 )
568562 return _resolve_query_without_cache_regular (
@@ -602,7 +596,6 @@ def _unload(
602596 data_source : str | None ,
603597 athena_query_wait_polling_delay : float ,
604598 execution_params : list [str ] | None ,
605- result_reuse_configuration : dict [str , Any ] | None = None ,
606599) -> _QueryMetadata :
607600 wg_config : _WorkGroupConfig = _get_workgroup_config (session = boto3_session , workgroup = workgroup )
608601 s3_output : str = _get_s3_output (s3_output = path , wg_config = wg_config , boto3_session = boto3_session )
@@ -635,7 +628,6 @@ def _unload(
635628 kms_key = kms_key ,
636629 boto3_session = boto3_session ,
637630 execution_params = execution_params ,
638- result_reuse_configuration = result_reuse_configuration ,
639631 )
640632 except botocore .exceptions .ClientError as ex :
641633 msg : str = str (ex )
@@ -797,6 +789,7 @@ def read_sql_query(
797789 athena_query_wait_polling_delay : float = _QUERY_WAIT_POLLING_DELAY ,
798790 params : dict [str , Any ] | list [str ] | None = None ,
799791 paramstyle : Literal ["qmark" , "named" ] = "named" ,
792+ result_reuse_configuration : dict [str , Any ] | None = None ,
800793 dtype_backend : Literal ["numpy_nullable" , "pyarrow" ] = "numpy_nullable" ,
801794 s3_additional_kwargs : dict [str , Any ] | None = None ,
802795 pyarrow_additional_kwargs : dict [str , Any ] | None = None ,
@@ -992,6 +985,10 @@ def read_sql_query(
992985
993986 - ``named``
994987 - ``qmark``
988+ result_reuse_configuration
989+ A structure that contains the configuration settings for reusing query results.
990+ This parameter is only valid when both `ctas_approach` and `unload_approach` are set to `False`.
991+ See also: https://docs.aws.amazon.com/athena/latest/ug/reusing-query-results.html
995992 dtype_backend
996993 Which dtype_backend to use, e.g. whether a DataFrame should have NumPy arrays,
997994 nullable dtypes are used for all dtypes that have a nullable implementation when
@@ -1052,6 +1049,10 @@ def read_sql_query(
10521049 raise exceptions .InvalidArgumentCombination (
10531050 "Using `client_request_token` is only allowed when `ctas_approach=False` and `unload_approach=False`."
10541051 )
1052+ if result_reuse_configuration and (ctas_approach or unload_approach ):
1053+ raise exceptions .InvalidArgumentCombination (
1054+ "Using `result_reuse_configuration` is only allowed when `ctas_approach=False` and `unload_approach=False`."
1055+ )
10551056 chunksize = sys .maxsize if ctas_approach is False and chunksize is True else chunksize
10561057
10571058 # Substitute query parameters if applicable
@@ -1116,7 +1117,7 @@ def read_sql_query(
11161117 boto3_session = boto3_session ,
11171118 pyarrow_additional_kwargs = pyarrow_additional_kwargs ,
11181119 execution_params = execution_params ,
1119- result_reuse_configuration = cache_info . result_reuse_configuration ,
1120+ result_reuse_configuration = result_reuse_configuration ,
11201121 dtype_backend = dtype_backend ,
11211122 client_request_token = client_request_token ,
11221123 )
@@ -1384,7 +1385,6 @@ def unload(
13841385 data_source : str | None = None ,
13851386 params : dict [str , Any ] | list [str ] | None = None ,
13861387 paramstyle : Literal ["qmark" , "named" ] = "named" ,
1387- result_reuse_configuration : dict [str , Any ] | None = None ,
13881388 athena_query_wait_polling_delay : float = _QUERY_WAIT_POLLING_DELAY ,
13891389) -> _QueryMetadata :
13901390 """Write query results from a SELECT statement to the specified data format using UNLOAD.
@@ -1473,5 +1473,4 @@ def unload(
14731473 boto3_session = boto3_session ,
14741474 data_source = data_source ,
14751475 execution_params = execution_params ,
1476- result_reuse_configuration = result_reuse_configuration ,
14771476 )
0 commit comments