diff --git a/awswrangler/_sql_formatter.py b/awswrangler/_sql_formatter.py index e38b9df96..5e653fa6d 100644 --- a/awswrangler/_sql_formatter.py +++ b/awswrangler/_sql_formatter.py @@ -155,7 +155,7 @@ def _format_parameters(params: dict[str, Any], engine: _Engine) -> dict[str, Any return processed_params -_PATTERN = re.compile(r":([A-Za-z0-9_]+)(?![A-Za-z0-9_])") +_PATTERN = re.compile(r"(? _Engine: diff --git a/tests/unit/test_sql_params_formatter.py b/tests/unit/test_sql_params_formatter.py index 20e470c10..76ba499b9 100644 --- a/tests/unit/test_sql_params_formatter.py +++ b/tests/unit/test_sql_params_formatter.py @@ -4,7 +4,13 @@ import pytest -from awswrangler._sql_formatter import _Engine, _format_parameters, _HiveEngine, _PrestoEngine +from awswrangler._sql_formatter import ( + _Engine, + _format_parameters, + _HiveEngine, + _PrestoEngine, + _process_sql_params, +) _hive_engine_param = pytest.param(_HiveEngine(), id="hive") _presto_engine_param = pytest.param(_PrestoEngine(), id="presto") @@ -118,3 +124,11 @@ class Point: {"point": Point(7, 1)}, engine=engine, ) + + +def test_process_sql_params_double_colon_cast() -> None: + sql = "SELECT col::text, col::timestamp FROM table WHERE id = :id AND status = :text" + params = {"id": 1, "text": "active"} + processed_sql = _process_sql_params(sql, params) + expected_sql = "SELECT col::text, col::timestamp FROM table WHERE id = 1 AND status = 'active'" + assert processed_sql == expected_sql