Skip to content

Commit 776cd0a

Browse files
Davide BissoDavide Bisso
Davide Bisso
authored and
Davide Bisso
committed
Adding NotebookVersion Parameter as specified in official AWS Docs https://docs.aws.amazon.com/athena/latest/APIReference/API_StartSession.html#athena-StartSession-request-NotebookVersion, this parameter is necessary to create session using Spark
1 parent 9a3842a commit 776cd0a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

awswrangler/athena/_spark.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def create_spark_session(
9494
default_executor_dpu_size: int = 1,
9595
additional_configs: dict[str, Any] | None = None,
9696
spark_properties: dict[str, Any] | None = None,
97+
notebook_version: str = 'Athena notebook version 1',
9798
idle_timeout: int = 15,
9899
boto3_session: boto3.Session | None = None,
99100
) -> str:
@@ -116,6 +117,9 @@ def create_spark_session(
116117
spark_properties: Dict[str, Any], optional
117118
Contains SparkProperties in the form of key-value pairs.Specifies custom jar files and Spark properties
118119
for use cases like cluster encryption, table formats, and general Spark tuning.
120+
notebook_version: str
121+
The notebook version. This value is supplied automatically for notebook sessions in the Athena console and is not required for programmatic session access.
122+
The only valid notebook version is Athena notebook version 1. If you specify a value for NotebookVersion, you must also specify a value for NotebookId
119123
idle_timeout : int, optional
120124
The idle timeout in minutes for the session. The default is 15.
121125
boto3_session : boto3.Session(), optional
@@ -146,6 +150,7 @@ def create_spark_session(
146150
WorkGroup=workgroup,
147151
EngineConfiguration=engine_configuration,
148152
SessionIdleTimeoutInMinutes=idle_timeout,
153+
NotebookVersion=notebook_version,
149154
)
150155
_logger.info("Session info:\n%s", response)
151156
session_id: str = response["SessionId"]
@@ -166,6 +171,7 @@ def run_spark_calculation(
166171
default_executor_dpu_size: int = 1,
167172
additional_configs: dict[str, Any] | None = None,
168173
spark_properties: dict[str, Any] | None = None,
174+
notebook_version: str = 'Athena notebook version 1',
169175
idle_timeout: int = 15,
170176
boto3_session: boto3.Session | None = None,
171177
) -> dict[str, Any]:
@@ -192,6 +198,9 @@ def run_spark_calculation(
192198
spark_properties: Dict[str, Any], optional
193199
Contains SparkProperties in the form of key-value pairs.Specifies custom jar files and Spark properties
194200
for use cases like cluster encryption, table formats, and general Spark tuning.
201+
notebook_version: str
202+
The notebook version. This value is supplied automatically for notebook sessions in the Athena console and is not required for programmatic session access.
203+
The only valid notebook version is Athena notebook version 1. If you specify a value for NotebookVersion, you must also specify a value for NotebookId
195204
idle_timeout : int, optional
196205
The idle timeout in minutes for the session. The default is 15.
197206
boto3_session : boto3.Session(), optional
@@ -221,6 +230,7 @@ def run_spark_calculation(
221230
default_executor_dpu_size=default_executor_dpu_size,
222231
additional_configs=additional_configs,
223232
spark_properties=spark_properties,
233+
notebook_version=notebook_version,
224234
idle_timeout=idle_timeout,
225235
boto3_session=boto3_session,
226236
)

0 commit comments

Comments
 (0)