Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: data_api uuid typehint #2961

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading