Skip to content

Commit

Permalink
fix: data_api uuid typehint (#2961)
Browse files Browse the repository at this point in the history
* fix data_api uuid typehint

* tests: add uuid case to unit test

* fix: sort deps correctly

---------

Co-authored-by: jaidisido <[email protected]>
  • Loading branch information
jethroguce and jaidisido authored Sep 30, 2024
1 parent 4bb8afc commit 5da8bde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions awswrangler/data_api/rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ def _create_value_dict( # noqa: PLR0911
if isinstance(value, Decimal):
return {"stringValue": str(value)}, "DECIMAL"

if isinstance(value, uuid.UUID):
return {"stringValue": str(value)}, "UUID"

raise exceptions.InvalidArgumentType(f"Value {value} not supported.")


Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_data_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import uuid
from typing import Any, Iterator

import boto3
Expand Down Expand Up @@ -284,7 +285,8 @@ def test_data_api_mysql_ansi(mysql_serverless_connector: "RdsDataApi", mysql_ser

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

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

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

0 comments on commit 5da8bde

Please sign in to comment.