Skip to content

Commit 5da8bde

Browse files
fix: data_api uuid typehint (#2961)
* fix data_api uuid typehint * tests: add uuid case to unit test * fix: sort deps correctly --------- Co-authored-by: jaidisido <[email protected]>
1 parent 4bb8afc commit 5da8bde

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

awswrangler/data_api/rds.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ def _create_value_dict( # noqa: PLR0911
359359
if isinstance(value, Decimal):
360360
return {"stringValue": str(value)}, "DECIMAL"
361361

362+
if isinstance(value, uuid.UUID):
363+
return {"stringValue": str(value)}, "UUID"
364+
362365
raise exceptions.InvalidArgumentType(f"Value {value} not supported.")
363366

364367

tests/unit/test_data_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import uuid
34
from typing import Any, Iterator
45

56
import boto3
@@ -284,7 +285,8 @@ def test_data_api_mysql_ansi(mysql_serverless_connector: "RdsDataApi", mysql_ser
284285

285286
def test_data_api_postgresql(postgresql_serverless_connector: "RdsDataApi", postgresql_serverless_table: str) -> None:
286287
database = "test"
287-
frame = pd.DataFrame([[42, "test"]], columns=["id", "name"])
288+
_id = uuid.uuid4()
289+
frame = pd.DataFrame([[_id, "test"]], columns=["id", "name"])
288290

289291
wr.data_api.rds.to_sql(
290292
df=frame,
@@ -295,7 +297,7 @@ def test_data_api_postgresql(postgresql_serverless_connector: "RdsDataApi", post
295297
)
296298

297299
out_frame = wr.data_api.rds.read_sql_query(
298-
f"SELECT name FROM {postgresql_serverless_table} WHERE id = 42", con=postgresql_serverless_connector
300+
f"SELECT name FROM {postgresql_serverless_table} WHERE id = '{_id}'", con=postgresql_serverless_connector
299301
)
300302
expected_dataframe = pd.DataFrame([["test"]], columns=["name"])
301303
assert_pandas_equals(out_frame, expected_dataframe)

0 commit comments

Comments
 (0)