Skip to content
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
2 changes: 1 addition & 1 deletion awswrangler/_sql_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"(?<!:):([A-Za-z0-9_]+)(?![A-Za-z0-9_])")


def _create_engine(engine_type: _EngineTypeLiteral) -> _Engine:
Expand Down
16 changes: 15 additions & 1 deletion tests/unit/test_sql_params_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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