@@ -427,6 +427,7 @@ def _resolve_query_without_cache_regular(
427427 s3_additional_kwargs : dict [str , Any ] | None ,
428428 boto3_session : boto3 .Session | None ,
429429 execution_params : list [str ] | None = None ,
430+ result_reuse_configuration : dict [str , Any ] | None = None ,
430431 dtype_backend : Literal ["numpy_nullable" , "pyarrow" ] = "numpy_nullable" ,
431432 client_request_token : str | None = None ,
432433) -> pd .DataFrame | Iterator [pd .DataFrame ]:
@@ -444,6 +445,7 @@ def _resolve_query_without_cache_regular(
444445 encryption = encryption ,
445446 kms_key = kms_key ,
446447 execution_params = execution_params ,
448+ result_reuse_configuration = result_reuse_configuration ,
447449 client_request_token = client_request_token ,
448450 boto3_session = boto3_session ,
449451 )
@@ -467,7 +469,7 @@ def _resolve_query_without_cache_regular(
467469 )
468470
469471
470- def _resolve_query_without_cache (
472+ def _resolve_query_without_cache ( # noqa: PLR0913
471473 sql : str ,
472474 database : str ,
473475 data_source : str | None ,
@@ -491,6 +493,7 @@ def _resolve_query_without_cache(
491493 boto3_session : boto3 .Session | None ,
492494 pyarrow_additional_kwargs : dict [str , Any ] | None = None ,
493495 execution_params : list [str ] | None = None ,
496+ result_reuse_configuration : dict [str , Any ] | None = None ,
494497 dtype_backend : Literal ["numpy_nullable" , "pyarrow" ] = "numpy_nullable" ,
495498 client_request_token : str | None = None ,
496499) -> pd .DataFrame | Iterator [pd .DataFrame ]:
@@ -572,6 +575,7 @@ def _resolve_query_without_cache(
572575 s3_additional_kwargs = s3_additional_kwargs ,
573576 boto3_session = boto3_session ,
574577 execution_params = execution_params ,
578+ result_reuse_configuration = result_reuse_configuration ,
575579 dtype_backend = dtype_backend ,
576580 client_request_token = client_request_token ,
577581 )
@@ -785,6 +789,7 @@ def read_sql_query(
785789 athena_query_wait_polling_delay : float = _QUERY_WAIT_POLLING_DELAY ,
786790 params : dict [str , Any ] | list [str ] | None = None ,
787791 paramstyle : Literal ["qmark" , "named" ] = "named" ,
792+ result_reuse_configuration : dict [str , Any ] | None = None ,
788793 dtype_backend : Literal ["numpy_nullable" , "pyarrow" ] = "numpy_nullable" ,
789794 s3_additional_kwargs : dict [str , Any ] | None = None ,
790795 pyarrow_additional_kwargs : dict [str , Any ] | None = None ,
@@ -980,6 +985,10 @@ def read_sql_query(
980985
981986 - ``named``
982987 - ``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
983992 dtype_backend
984993 Which dtype_backend to use, e.g. whether a DataFrame should have NumPy arrays,
985994 nullable dtypes are used for all dtypes that have a nullable implementation when
@@ -1040,6 +1049,10 @@ def read_sql_query(
10401049 raise exceptions .InvalidArgumentCombination (
10411050 "Using `client_request_token` is only allowed when `ctas_approach=False` and `unload_approach=False`."
10421051 )
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+ )
10431056 chunksize = sys .maxsize if ctas_approach is False and chunksize is True else chunksize
10441057
10451058 # Substitute query parameters if applicable
@@ -1104,6 +1117,7 @@ def read_sql_query(
11041117 boto3_session = boto3_session ,
11051118 pyarrow_additional_kwargs = pyarrow_additional_kwargs ,
11061119 execution_params = execution_params ,
1120+ result_reuse_configuration = result_reuse_configuration ,
11071121 dtype_backend = dtype_backend ,
11081122 client_request_token = client_request_token ,
11091123 )
0 commit comments