From c4430adba438df0b8a0b5f74b2950767f1e46ce6 Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Mon, 30 Nov 2026 20:01:40 +0900 Subject: [PATCH 1/6] Require SQLAlchemy 2.0.52 (GH-1574) From SQLAlchemy 2.0.52, the literal processors of Numeric and Float check that a value is a number before rendering it unquoted, so a non-numeric string in a literal_execute parameter or with literal_binds raises CompileError instead of becoming SQL text. PyAthena's AthenaFloat and AthenaNumeric pass such values to those processors (#1573), but 2.0.44 to 2.0.51 still render str(value). Require 2.0.52 for the sqlalchemy and aiosqlalchemy extras and the dev group, and lock 2.0.58, the latest 2.0 release. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +-- docs/introduction.md | 4 +-- docs/sqlalchemy.md | 4 +-- pyproject.toml | 6 ++-- uv.lock | 85 ++++++++++++++++++++++---------------------- 5 files changed, 51 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 240b31f04..0cc284f23 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ Extra packages: | Package | Install command | Version | |---------------|-----------------------------------------|----------| -| SQLAlchemy | `pip install PyAthena[SQLAlchemy]` | >=2.0.44 | -| AioSQLAlchemy | `pip install PyAthena[AioSQLAlchemy]` | >=2.0.44 | +| SQLAlchemy | `pip install PyAthena[SQLAlchemy]` | >=2.0.52 | +| AioSQLAlchemy | `pip install PyAthena[AioSQLAlchemy]` | >=2.0.52 | | pandas | `pip install PyAthena[Pandas]` | >=3.0.0 | | Arrow | `pip install PyAthena[Arrow]` | >=22.0.0 | | Polars | `pip install PyAthena[Polars]` | >=1.39.0 | diff --git a/docs/introduction.md b/docs/introduction.md index 5250cc7e7..ec8012c33 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -31,8 +31,8 @@ Extra packages: | Package | Install command | Version | |---------------|-----------------------------------------|----------| -| SQLAlchemy | `pip install PyAthena[SQLAlchemy]` | >=2.0.44 | -| AioSQLAlchemy | `pip install PyAthena[AioSQLAlchemy]` | >=2.0.44 | +| SQLAlchemy | `pip install PyAthena[SQLAlchemy]` | >=2.0.52 | +| AioSQLAlchemy | `pip install PyAthena[AioSQLAlchemy]` | >=2.0.52 | | pandas | `pip install PyAthena[Pandas]` | >=3.0.0 | | Arrow | `pip install PyAthena[Arrow]` | >=22.0.0 | | Polars | `pip install PyAthena[Polars]` | >=1.39.0 | diff --git a/docs/sqlalchemy.md b/docs/sqlalchemy.md index eb267f236..9858209ad 100644 --- a/docs/sqlalchemy.md +++ b/docs/sqlalchemy.md @@ -2,8 +2,8 @@ # SQLAlchemy -Install SQLAlchemy with `pip install "SQLAlchemy>=2.0.44"` or `pip install PyAthena[sqlalchemy]`. -Supported SQLAlchemy is 2.0.44 or higher. +Install SQLAlchemy with `pip install "SQLAlchemy>=2.0.52"` or `pip install PyAthena[sqlalchemy]`. +Supported SQLAlchemy is 2.0.52 or higher. For async support (`create_async_engine`), install with `pip install PyAthena[aiosqlalchemy]`. diff --git a/pyproject.toml b/pyproject.toml index 1f3e9672e..d70cb7844 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,9 +73,9 @@ awsathena = "pyathena.sqlalchemy.rest:AthenaRestDialect" "awsathena.aios3fs" = "pyathena.aio.sqlalchemy.s3fs:AthenaAioS3FSDialect" [project.optional-dependencies] -sqlalchemy = ["sqlalchemy>=2.0.44"] +sqlalchemy = ["sqlalchemy>=2.0.52"] aiosqlalchemy = [ - "sqlalchemy[asyncio]>=2.0.44", + "sqlalchemy[asyncio]>=2.0.52", ] pandas = [ "pandas>=3.0.0", @@ -89,7 +89,7 @@ polars = [ [dependency-groups] dev = [ - "sqlalchemy[asyncio]>=2.0.44", + "sqlalchemy[asyncio]>=2.0.52", "pandas>=3.0.0", "pyarrow>=22.0.0", "polars>=1.39.0", diff --git a/uv.lock b/uv.lock index 5e48758df..cbac22369 100644 --- a/uv.lock +++ b/uv.lock @@ -1934,8 +1934,8 @@ requires-dist = [ { name = "pandas", marker = "extra == 'pandas'", specifier = ">=3.0.0" }, { name = "polars", marker = "extra == 'polars'", specifier = ">=1.39.0" }, { name = "pyarrow", marker = "extra == 'arrow'", specifier = ">=22.0.0" }, - { name = "sqlalchemy", marker = "extra == 'sqlalchemy'", specifier = ">=2.0.44" }, - { name = "sqlalchemy", extras = ["asyncio"], marker = "extra == 'aiosqlalchemy'", specifier = ">=2.0.44" }, + { name = "sqlalchemy", marker = "extra == 'sqlalchemy'", specifier = ">=2.0.52" }, + { name = "sqlalchemy", extras = ["asyncio"], marker = "extra == 'aiosqlalchemy'", specifier = ">=2.0.52" }, { name = "tenacity", specifier = ">=8.0.1" }, { name = "tzdata", specifier = ">=2024.2" }, ] @@ -1963,7 +1963,7 @@ dev = [ { name = "sphinx-design" }, { name = "sphinx-multiversion" }, { name = "sphinxext-opengraph" }, - { name = "sqlalchemy", extras = ["asyncio"], specifier = ">=2.0.44" }, + { name = "sqlalchemy", extras = ["asyncio"], specifier = ">=2.0.52" }, ] [[package]] @@ -2532,51 +2532,50 @@ wheels = [ [[package]] name = "sqlalchemy" -version = "2.0.46" +version = "2.0.58" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "greenlet", marker = "platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/06/aa/9ce0f3e7a9829ead5c8ce549392f33a12c4555a6c0609bb27d882e9c7ddf/sqlalchemy-2.0.46.tar.gz", hash = "sha256:cf36851ee7219c170bb0793dbc3da3e80c582e04a5437bc601bfe8c85c9216d7", size = 9865393, upload-time = "2026-01-21T18:03:45.119Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/69/ac/b42ad16800d0885105b59380ad69aad0cce5a65276e269ce2729a2343b6a/sqlalchemy-2.0.46-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:261c4b1f101b4a411154f1da2b76497d73abbfc42740029205d4d01fa1052684", size = 2154851, upload-time = "2026-01-21T18:27:30.54Z" }, - { url = "https://files.pythonhosted.org/packages/a0/60/d8710068cb79f64d002ebed62a7263c00c8fd95f4ebd4b5be8f7ca93f2bc/sqlalchemy-2.0.46-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:181903fe8c1b9082995325f1b2e84ac078b1189e2819380c2303a5f90e114a62", size = 3311241, upload-time = "2026-01-21T18:32:33.45Z" }, - { url = "https://files.pythonhosted.org/packages/2b/0f/20c71487c7219ab3aa7421c7c62d93824c97c1460f2e8bb72404b0192d13/sqlalchemy-2.0.46-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:590be24e20e2424a4c3c1b0835e9405fa3d0af5823a1a9fc02e5dff56471515f", size = 3310741, upload-time = "2026-01-21T18:44:57.887Z" }, - { url = "https://files.pythonhosted.org/packages/65/80/d26d00b3b249ae000eee4db206fcfc564bf6ca5030e4747adf451f4b5108/sqlalchemy-2.0.46-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7568fe771f974abadce52669ef3a03150ff03186d8eb82613bc8adc435a03f01", size = 3263116, upload-time = "2026-01-21T18:32:35.044Z" }, - { url = "https://files.pythonhosted.org/packages/da/ee/74dda7506640923821340541e8e45bd3edd8df78664f1f2e0aae8077192b/sqlalchemy-2.0.46-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ebf7e1e78af38047e08836d33502c7a278915698b7c2145d045f780201679999", size = 3285327, upload-time = "2026-01-21T18:44:59.254Z" }, - { url = "https://files.pythonhosted.org/packages/9f/25/6dcf8abafff1389a21c7185364de145107b7394ecdcb05233815b236330d/sqlalchemy-2.0.46-cp311-cp311-win32.whl", hash = "sha256:9d80ea2ac519c364a7286e8d765d6cd08648f5b21ca855a8017d9871f075542d", size = 2114564, upload-time = "2026-01-21T18:33:15.85Z" }, - { url = "https://files.pythonhosted.org/packages/93/5f/e081490f8523adc0088f777e4ebad3cac21e498ec8a3d4067074e21447a1/sqlalchemy-2.0.46-cp311-cp311-win_amd64.whl", hash = "sha256:585af6afe518732d9ccd3aea33af2edaae4a7aa881af5d8f6f4fe3a368699597", size = 2139233, upload-time = "2026-01-21T18:33:17.528Z" }, - { url = "https://files.pythonhosted.org/packages/b6/35/d16bfa235c8b7caba3730bba43e20b1e376d2224f407c178fbf59559f23e/sqlalchemy-2.0.46-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3a9a72b0da8387f15d5810f1facca8f879de9b85af8c645138cba61ea147968c", size = 2153405, upload-time = "2026-01-21T19:05:54.143Z" }, - { url = "https://files.pythonhosted.org/packages/06/6c/3192e24486749862f495ddc6584ed730c0c994a67550ec395d872a2ad650/sqlalchemy-2.0.46-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2347c3f0efc4de367ba00218e0ae5c4ba2306e47216ef80d6e31761ac97cb0b9", size = 3334702, upload-time = "2026-01-21T18:46:45.384Z" }, - { url = "https://files.pythonhosted.org/packages/ea/a2/b9f33c8d68a3747d972a0bb758c6b63691f8fb8a49014bc3379ba15d4274/sqlalchemy-2.0.46-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9094c8b3197db12aa6f05c51c05daaad0a92b8c9af5388569847b03b1007fb1b", size = 3347664, upload-time = "2026-01-21T18:40:09.979Z" }, - { url = "https://files.pythonhosted.org/packages/aa/d2/3e59e2a91eaec9db7e8dc6b37b91489b5caeb054f670f32c95bcba98940f/sqlalchemy-2.0.46-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:37fee2164cf21417478b6a906adc1a91d69ae9aba8f9533e67ce882f4bb1de53", size = 3277372, upload-time = "2026-01-21T18:46:47.168Z" }, - { url = "https://files.pythonhosted.org/packages/dd/dd/67bc2e368b524e2192c3927b423798deda72c003e73a1e94c21e74b20a85/sqlalchemy-2.0.46-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b1e14b2f6965a685c7128bd315e27387205429c2e339eeec55cb75ca4ab0ea2e", size = 3312425, upload-time = "2026-01-21T18:40:11.548Z" }, - { url = "https://files.pythonhosted.org/packages/43/82/0ecd68e172bfe62247e96cb47867c2d68752566811a4e8c9d8f6e7c38a65/sqlalchemy-2.0.46-cp312-cp312-win32.whl", hash = "sha256:412f26bb4ba942d52016edc8d12fb15d91d3cd46b0047ba46e424213ad407bcb", size = 2113155, upload-time = "2026-01-21T18:42:49.748Z" }, - { url = "https://files.pythonhosted.org/packages/bc/2a/2821a45742073fc0331dc132552b30de68ba9563230853437cac54b2b53e/sqlalchemy-2.0.46-cp312-cp312-win_amd64.whl", hash = "sha256:ea3cd46b6713a10216323cda3333514944e510aa691c945334713fca6b5279ff", size = 2140078, upload-time = "2026-01-21T18:42:51.197Z" }, - { url = "https://files.pythonhosted.org/packages/b3/4b/fa7838fe20bb752810feed60e45625a9a8b0102c0c09971e2d1d95362992/sqlalchemy-2.0.46-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:93a12da97cca70cea10d4b4fc602589c4511f96c1f8f6c11817620c021d21d00", size = 2150268, upload-time = "2026-01-21T19:05:56.621Z" }, - { url = "https://files.pythonhosted.org/packages/46/c1/b34dccd712e8ea846edf396e00973dda82d598cb93762e55e43e6835eba9/sqlalchemy-2.0.46-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:af865c18752d416798dae13f83f38927c52f085c52e2f32b8ab0fef46fdd02c2", size = 3276511, upload-time = "2026-01-21T18:46:49.022Z" }, - { url = "https://files.pythonhosted.org/packages/96/48/a04d9c94753e5d5d096c628c82a98c4793b9c08ca0e7155c3eb7d7db9f24/sqlalchemy-2.0.46-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8d679b5f318423eacb61f933a9a0f75535bfca7056daeadbf6bd5bcee6183aee", size = 3292881, upload-time = "2026-01-21T18:40:13.089Z" }, - { url = "https://files.pythonhosted.org/packages/be/f4/06eda6e91476f90a7d8058f74311cb65a2fb68d988171aced81707189131/sqlalchemy-2.0.46-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:64901e08c33462acc9ec3bad27fc7a5c2b6491665f2aa57564e57a4f5d7c52ad", size = 3224559, upload-time = "2026-01-21T18:46:50.974Z" }, - { url = "https://files.pythonhosted.org/packages/ab/a2/d2af04095412ca6345ac22b33b89fe8d6f32a481e613ffcb2377d931d8d0/sqlalchemy-2.0.46-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e8ac45e8f4eaac0f9f8043ea0e224158855c6a4329fd4ee37c45c61e3beb518e", size = 3262728, upload-time = "2026-01-21T18:40:14.883Z" }, - { url = "https://files.pythonhosted.org/packages/31/48/1980c7caa5978a3b8225b4d230e69a2a6538a3562b8b31cea679b6933c83/sqlalchemy-2.0.46-cp313-cp313-win32.whl", hash = "sha256:8d3b44b3d0ab2f1319d71d9863d76eeb46766f8cf9e921ac293511804d39813f", size = 2111295, upload-time = "2026-01-21T18:42:52.366Z" }, - { url = "https://files.pythonhosted.org/packages/2d/54/f8d65bbde3d877617c4720f3c9f60e99bb7266df0d5d78b6e25e7c149f35/sqlalchemy-2.0.46-cp313-cp313-win_amd64.whl", hash = "sha256:77f8071d8fbcbb2dd11b7fd40dedd04e8ebe2eb80497916efedba844298065ef", size = 2137076, upload-time = "2026-01-21T18:42:53.924Z" }, - { url = "https://files.pythonhosted.org/packages/56/ba/9be4f97c7eb2b9d5544f2624adfc2853e796ed51d2bb8aec90bc94b7137e/sqlalchemy-2.0.46-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a1e8cc6cc01da346dc92d9509a63033b9b1bda4fed7a7a7807ed385c7dccdc10", size = 3556533, upload-time = "2026-01-21T18:33:06.636Z" }, - { url = "https://files.pythonhosted.org/packages/20/a6/b1fc6634564dbb4415b7ed6419cdfeaadefd2c39cdab1e3aa07a5f2474c2/sqlalchemy-2.0.46-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:96c7cca1a4babaaf3bfff3e4e606e38578856917e52f0384635a95b226c87764", size = 3523208, upload-time = "2026-01-21T18:45:08.436Z" }, - { url = "https://files.pythonhosted.org/packages/a1/d8/41e0bdfc0f930ff236f86fccd12962d8fa03713f17ed57332d38af6a3782/sqlalchemy-2.0.46-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:b2a9f9aee38039cf4755891a1e50e1effcc42ea6ba053743f452c372c3152b1b", size = 3464292, upload-time = "2026-01-21T18:33:08.208Z" }, - { url = "https://files.pythonhosted.org/packages/f0/8b/9dcbec62d95bea85f5ecad9b8d65b78cc30fb0ffceeb3597961f3712549b/sqlalchemy-2.0.46-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:db23b1bf8cfe1f7fda19018e7207b20cdb5168f83c437ff7e95d19e39289c447", size = 3473497, upload-time = "2026-01-21T18:45:10.552Z" }, - { url = "https://files.pythonhosted.org/packages/e9/f8/5ecdfc73383ec496de038ed1614de9e740a82db9ad67e6e4514ebc0708a3/sqlalchemy-2.0.46-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:56bdd261bfd0895452006d5316cbf35739c53b9bb71a170a331fa0ea560b2ada", size = 2152079, upload-time = "2026-01-21T19:05:58.477Z" }, - { url = "https://files.pythonhosted.org/packages/e5/bf/eba3036be7663ce4d9c050bc3d63794dc29fbe01691f2bf5ccb64e048d20/sqlalchemy-2.0.46-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:33e462154edb9493f6c3ad2125931e273bbd0be8ae53f3ecd1c161ea9a1dd366", size = 3272216, upload-time = "2026-01-21T18:46:52.634Z" }, - { url = "https://files.pythonhosted.org/packages/05/45/1256fb597bb83b58a01ddb600c59fe6fdf0e5afe333f0456ed75c0f8d7bd/sqlalchemy-2.0.46-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9bcdce05f056622a632f1d44bb47dbdb677f58cad393612280406ce37530eb6d", size = 3277208, upload-time = "2026-01-21T18:40:16.38Z" }, - { url = "https://files.pythonhosted.org/packages/d9/a0/2053b39e4e63b5d7ceb3372cface0859a067c1ddbd575ea7e9985716f771/sqlalchemy-2.0.46-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:8e84b09a9b0f19accedcbeff5c2caf36e0dd537341a33aad8d680336152dc34e", size = 3221994, upload-time = "2026-01-21T18:46:54.622Z" }, - { url = "https://files.pythonhosted.org/packages/1e/87/97713497d9502553c68f105a1cb62786ba1ee91dea3852ae4067ed956a50/sqlalchemy-2.0.46-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4f52f7291a92381e9b4de9050b0a65ce5d6a763333406861e33906b8aa4906bf", size = 3243990, upload-time = "2026-01-21T18:40:18.253Z" }, - { url = "https://files.pythonhosted.org/packages/a8/87/5d1b23548f420ff823c236f8bea36b1a997250fd2f892e44a3838ca424f4/sqlalchemy-2.0.46-cp314-cp314-win32.whl", hash = "sha256:70ed2830b169a9960193f4d4322d22be5c0925357d82cbf485b3369893350908", size = 2114215, upload-time = "2026-01-21T18:42:55.232Z" }, - { url = "https://files.pythonhosted.org/packages/3a/20/555f39cbcf0c10cf452988b6a93c2a12495035f68b3dbd1a408531049d31/sqlalchemy-2.0.46-cp314-cp314-win_amd64.whl", hash = "sha256:3c32e993bc57be6d177f7d5d31edb93f30726d798ad86ff9066d75d9bf2e0b6b", size = 2139867, upload-time = "2026-01-21T18:42:56.474Z" }, - { url = "https://files.pythonhosted.org/packages/3e/f0/f96c8057c982d9d8a7a68f45d69c674bc6f78cad401099692fe16521640a/sqlalchemy-2.0.46-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4dafb537740eef640c4d6a7c254611dca2df87eaf6d14d6a5fca9d1f4c3fc0fa", size = 3561202, upload-time = "2026-01-21T18:33:10.337Z" }, - { url = "https://files.pythonhosted.org/packages/d7/53/3b37dda0a5b137f21ef608d8dfc77b08477bab0fe2ac9d3e0a66eaeab6fc/sqlalchemy-2.0.46-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:42a1643dc5427b69aca967dae540a90b0fbf57eaf248f13a90ea5930e0966863", size = 3526296, upload-time = "2026-01-21T18:45:12.657Z" }, - { url = "https://files.pythonhosted.org/packages/33/75/f28622ba6dde79cd545055ea7bd4062dc934e0621f7b3be2891f8563f8de/sqlalchemy-2.0.46-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ff33c6e6ad006bbc0f34f5faf941cfc62c45841c64c0a058ac38c799f15b5ede", size = 3470008, upload-time = "2026-01-21T18:33:11.725Z" }, - { url = "https://files.pythonhosted.org/packages/a9/42/4afecbbc38d5e99b18acef446453c76eec6fbd03db0a457a12a056836e22/sqlalchemy-2.0.46-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:82ec52100ec1e6ec671563bbd02d7c7c8d0b9e71a0723c72f22ecf52d1755330", size = 3476137, upload-time = "2026-01-21T18:45:15.001Z" }, - { url = "https://files.pythonhosted.org/packages/fc/a1/9c4efa03300926601c19c18582531b45aededfb961ab3c3585f1e24f120b/sqlalchemy-2.0.46-py3-none-any.whl", hash = "sha256:f9c11766e7e7c0a2767dda5acb006a118640c9fc0a4104214b96269bfb78399e", size = 1937882, upload-time = "2026-01-21T18:22:10.456Z" }, +sdist = { url = "https://files.pythonhosted.org/packages/74/9a/8d798711d1e56fa5f51152c228c2e0a8f03c95f3d59c969dd720ed492b83/sqlalchemy-2.0.58.tar.gz", hash = "sha256:2acdcec9836b7c1514a9ad426e7731669a1186d96481a2e82c50bf2aebb49061", size = 10031998, upload-time = "2026-11-16T20:40:44.535Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/58/c32d1f92729e9eac59029d0fc6cb98f5f359bc30682e9df3b358ec766b83/sqlalchemy-2.0.58-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:213bb891991c71286c7149df147c8dfbce2e228e1b2f5177bf2b67435a33db13", size = 2199394, upload-time = "2026-11-16T20:58:55.958Z" }, + { url = "https://files.pythonhosted.org/packages/12/ec/735003c6d2cfcae34892c1faf0ebe5b159b18c15063148db4458387f3032/sqlalchemy-2.0.58-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ec4785da1b73083bd36046af672bca430a739d13bbd359e5b0a0c42e76df9896", size = 3442427, upload-time = "2026-11-16T21:03:33.668Z" }, + { url = "https://files.pythonhosted.org/packages/3f/97/0e8ab2e98f4d9a2e3e65cc08dedd10470b2e149629f3736fbcfc5818e0d0/sqlalchemy-2.0.58-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3be707b48a7aa68f987ed82b219dff32de67677402a0c05356a631ec0ed86e4d", size = 3440588, upload-time = "2026-11-16T20:57:25.025Z" }, + { url = "https://files.pythonhosted.org/packages/67/0d/81032d86dbfd50a3621a2b3be32aa3eb414e0d492ac941514974f697d2c1/sqlalchemy-2.0.58-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:cdf2c956130bc3570dd2312d81d93259976716d8e9fa002dd4952be05180c328", size = 3394221, upload-time = "2026-11-16T21:03:35.456Z" }, + { url = "https://files.pythonhosted.org/packages/55/bf/162e30005a60af95d55cabab9aabee71c076da122a6c9bbaba062e7132ad/sqlalchemy-2.0.58-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9d73d70d1ad20f54064c6f0473d365c850b5abe51bce4846656799b9a7759064", size = 3417618, upload-time = "2026-11-16T20:57:26.739Z" }, + { url = "https://files.pythonhosted.org/packages/fa/8e/0ba7a4e2bfd52c00ac1ac92fcbb47cba20558a6399dfc910ad6fbea02f51/sqlalchemy-2.0.58-cp311-cp311-win32.whl", hash = "sha256:7c1f254be594c32a3ccf45f5ff630191faf79fd1e847c3a37ce4588e7f1329d9", size = 2154185, upload-time = "2026-11-16T21:07:07.55Z" }, + { url = "https://files.pythonhosted.org/packages/39/ad/25ac6d3d63816937d733e8f4f6c214275ee4afbf3ed2ead746fee7a7ff7a/sqlalchemy-2.0.58-cp311-cp311-win_amd64.whl", hash = "sha256:372e4cbf8b189ade90f8d88440f1c1f934fb99d20416dc562a35d7e628756467", size = 2180944, upload-time = "2026-11-16T21:07:09.248Z" }, + { url = "https://files.pythonhosted.org/packages/4a/5e/34422c5ae9d572c8a61b77ac13a64d8963c4acad72653c3551a18e2f5904/sqlalchemy-2.0.58-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:852b9ead092376348d3f2e7600b8f4d388fef7d4d1c37b15d56456393c657f00", size = 2199184, upload-time = "2026-11-16T20:58:57.582Z" }, + { url = "https://files.pythonhosted.org/packages/68/6e/7b37ebcf7ba994f5d1c3d4bb963d4105a02de3831b9279ee34576b19b6ab/sqlalchemy-2.0.58-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:653c936876b581098c65b60a627706ce9566cbdf46d30ca0e3f839e88990a933", size = 3463395, upload-time = "2026-11-16T21:03:37.258Z" }, + { url = "https://files.pythonhosted.org/packages/cd/b8/85f6ee0ee2c9075f20ea2d9c698ab5bc734336ae89105026e153d07d12e3/sqlalchemy-2.0.58-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:301f32a68df64c66226ade47a520e360595177ee77986fcc4e62abfe6e002b97", size = 3480085, upload-time = "2026-11-16T20:57:28.403Z" }, + { url = "https://files.pythonhosted.org/packages/a2/cc/c03a9c6a36447fe0f4aa98be82caf3db2b4707d995bed801c6b76267d364/sqlalchemy-2.0.58-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4e2a03aeee8eee6bb9b375628f64cac6ac13251fa985e2d062178fa8e9373705", size = 3414855, upload-time = "2026-11-16T21:03:39.593Z" }, + { url = "https://files.pythonhosted.org/packages/14/e7/0063a07b5820c850fe77e944f5d6a0fc9d3689ddd44009f14f03c9e6e126/sqlalchemy-2.0.58-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c85243a35a10c977732ce164d96ff85558a79dd2f9547c9659dd438c3a42ad45", size = 3446091, upload-time = "2026-11-16T20:57:30.08Z" }, + { url = "https://files.pythonhosted.org/packages/aa/03/b3819d8a0e4935e5e630e53e03c35b80117d7f5a9041b302660eecccaea6/sqlalchemy-2.0.58-cp312-cp312-win32.whl", hash = "sha256:50d3b6cdfa8c32ebe308be885467d983bb3d4b7b01785049a94b179852ee4981", size = 2152509, upload-time = "2026-11-16T21:07:10.686Z" }, + { url = "https://files.pythonhosted.org/packages/b5/cf/95becaaa2690a8c5a92238337590948323da9af5644d903422266b473db4/sqlalchemy-2.0.58-cp312-cp312-win_amd64.whl", hash = "sha256:1b1c331969dd007459569baa1030550875dc106da2a2b60dd159406e9f59f366", size = 2181885, upload-time = "2026-11-16T21:07:12.413Z" }, + { url = "https://files.pythonhosted.org/packages/79/d0/d232d4d3797d6903330e19768b1b38ccec5a770cc2395a51d76ad1b779a6/sqlalchemy-2.0.58-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:4a57e2c3251c9888957138dadda6d51e54b150d549e97410b0b4df49accefe07", size = 2195829, upload-time = "2026-11-16T20:57:43.473Z" }, + { url = "https://files.pythonhosted.org/packages/c2/9e/e5e403afe39fb434f21467b82e9a5fdfbb7b18a43aa09347e3c027fd73b6/sqlalchemy-2.0.58-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:950220a3e9ff4645e27b98a329c2513a2232803e16c11d751efe152925c62511", size = 3413448, upload-time = "2026-11-16T20:55:32.643Z" }, + { url = "https://files.pythonhosted.org/packages/5c/5b/cb84f21b67aebf16b3f6d2d9921f23f032906ed2435db6bd3a4207551605/sqlalchemy-2.0.58-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3590f4448b85c79c71d133de3f5dcc412cbad1c43c31576b0db123ff26e3e611", size = 3431756, upload-time = "2026-11-16T21:13:42.545Z" }, + { url = "https://files.pythonhosted.org/packages/33/38/0b815e7777c18df5e68f8000732625ccf7c5a7fd536fa36cdead4afdd9ed/sqlalchemy-2.0.58-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:5db9d449fc2053a9993ea5a8aa9632f89bceb28fe7bcdd6e99ccbc0bf234d655", size = 3362880, upload-time = "2026-11-16T20:55:34.609Z" }, + { url = "https://files.pythonhosted.org/packages/86/bf/30e408ebd15ec67c9f0429783c2b8f673794c2d31d24bc6b1de8eaba25b5/sqlalchemy-2.0.58-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:0f403c8f2e6c9739c70e122c18d4f4ea244f6477d7a76dc57f83ecb599c4b0e6", size = 3398060, upload-time = "2026-11-16T21:13:44.472Z" }, + { url = "https://files.pythonhosted.org/packages/f0/8b/7119194ab277d4d783401e0fc4c8950679922db57b88d37acae3b3073084/sqlalchemy-2.0.58-cp313-cp313-win32.whl", hash = "sha256:e7e161ddb7be8cb941991d5c9057bd70715cd71e0bc25ea68daf08361f85eb6b", size = 2150659, upload-time = "2026-11-16T20:57:58.38Z" }, + { url = "https://files.pythonhosted.org/packages/21/41/729351f0b66e9d6d43380d504cfaa3a807704a62b62f6c3b2b327d211046/sqlalchemy-2.0.58-cp313-cp313-win_amd64.whl", hash = "sha256:d789a5f5a8a1e062f9deb59c7736e32c2d6c9532a358919083a234cdf720cbf3", size = 2178361, upload-time = "2026-11-16T20:58:00.11Z" }, + { url = "https://files.pythonhosted.org/packages/cf/e2/d62aeaf8ab3fb9d232c3fb7e92a785e44590786b7d28e8a9244f78f7f7c8/sqlalchemy-2.0.58-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:4c8be3acd308171a252399801bba6c4fbabe6c596d9adbd4ea8d698bb9248325", size = 2197405, upload-time = "2026-11-16T20:57:45.047Z" }, + { url = "https://files.pythonhosted.org/packages/c2/fd/1d85b9f9cff8a564e4e9b6ed515900a9a7bad0b67560d66e18a2a3c85f89/sqlalchemy-2.0.58-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fde99c943328a004227abb5c72c45d072d6c4d877f2a4e560a6f743bfcb6f215", size = 3409360, upload-time = "2026-11-16T20:55:36.217Z" }, + { url = "https://files.pythonhosted.org/packages/22/a6/d2cb9911cfae073381235c7cf31d7bcac5d6e919a768fcd3932ba12fdca2/sqlalchemy-2.0.58-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b08475f3bcbf5f6c10654874601c8a8ef5b50e2c8c944d8cbf6a4d81618c2ba1", size = 3417154, upload-time = "2026-11-16T21:13:46.448Z" }, + { url = "https://files.pythonhosted.org/packages/1a/67/c93cdce7c0fb7d6f0b78c5321ce36514ded95a5b329a30a498b9d34da950/sqlalchemy-2.0.58-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:824259061cabbc0e1a3c413667411a7f8b256e921a19bf8557cd26b427fd95b7", size = 3357286, upload-time = "2026-11-16T20:55:37.811Z" }, + { url = "https://files.pythonhosted.org/packages/22/f7/03dcdb19543e40cc4b33caa7af663085ee8a82ce78be673132cc32fcccff/sqlalchemy-2.0.58-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:affe34a87f54ea099f6be8739c1b1b61b47f01abd2e04b72abcce946e1be5540", size = 3387980, upload-time = "2026-11-16T21:13:48.293Z" }, + { url = "https://files.pythonhosted.org/packages/c0/60/175e494bf82dd0d82af37fb63297b41545c0026acb6e1ad18fec7d151de0/sqlalchemy-2.0.58-cp314-cp314-win32.whl", hash = "sha256:2fbe18e6597f4853d49928f3e6faef549283863249bc53bf63b3fedb0165f3c9", size = 2153873, upload-time = "2026-11-16T20:58:01.611Z" }, + { url = "https://files.pythonhosted.org/packages/10/22/2ba5feac1f52ff0697ab6ca4d4ce850f322f2a41809e79cd5231b3c03eaa/sqlalchemy-2.0.58-cp314-cp314-win_amd64.whl", hash = "sha256:004b0953665695f00e9c7f4f5c4a42e778477979ef5571a9321bfdd020dbce1a", size = 2181155, upload-time = "2026-11-16T20:58:03.102Z" }, + { url = "https://files.pythonhosted.org/packages/8b/98/b1b8bd5862fead65baec875040a416c4f2f17f3b9832e1b2e1c4d7e7a829/sqlalchemy-2.0.58-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:a3ce7d6725cbc6e08bcb0930ec8f8f633a23f2cbbe116742606896cfb28e6660", size = 2220432, upload-time = "2026-11-16T21:04:35.004Z" }, + { url = "https://files.pythonhosted.org/packages/23/88/88c3b788c525b53aadc83d3a91d22ee48f29a190b4bc8e6108b6c696143c/sqlalchemy-2.0.58-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:da339dd11c63f7cd4c008eb559dfe5b62d649d552f9e682492da0566758dfcf1", size = 3673138, upload-time = "2026-11-16T21:04:16.794Z" }, + { url = "https://files.pythonhosted.org/packages/44/68/747a84a0d7989a3972a88a483f7b0f27b781843bcfc480dac56cecefca76/sqlalchemy-2.0.58-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:580ab42500e9aee41e59ea0ab345876a2ba5d51998646d647b8de19882c7fb3f", size = 3636128, upload-time = "2026-11-16T20:56:21.215Z" }, + { url = "https://files.pythonhosted.org/packages/4e/87/70ed21d2e8f80213247d5ccf25092e7a9fef0f17c0a26de4a44f64f8f334/sqlalchemy-2.0.58-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:fa33ecb306f0c7e03e318e373f75dc8960627dc1e05238fae4a702d14524bee5", size = 3576029, upload-time = "2026-11-16T21:04:18.575Z" }, + { url = "https://files.pythonhosted.org/packages/d1/33/694e022f776af76fc353918581351bb80c2280966004352f908fc2a6f773/sqlalchemy-2.0.58-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:a54cec4e1ca0cf64e57bc7ef07a23a578114bd9d4db65bc7b15c5e80904e5b32", size = 3588380, upload-time = "2026-11-16T20:56:22.836Z" }, + { url = "https://files.pythonhosted.org/packages/cf/07/a521b2d5f8b9f02ed761ca7fa092d9f4132c2da90a07690e9fe032d68104/sqlalchemy-2.0.58-cp314-cp314t-win32.whl", hash = "sha256:8f35a02df719004e833d5ae98b30fd383932c45266bd3b41f7a629ba42d0ad4f", size = 2186782, upload-time = "2026-11-16T20:57:51.74Z" }, + { url = "https://files.pythonhosted.org/packages/38/6d/05d4df782be86de6586644eebe22bdbe976b556b92995474057a6d54eb48/sqlalchemy-2.0.58-cp314-cp314t-win_amd64.whl", hash = "sha256:a2b57ca913808beb9c0217819e0189950f019ad5c704e250c850adc9bfc6edb1", size = 2224171, upload-time = "2026-11-16T20:57:53.541Z" }, + { url = "https://files.pythonhosted.org/packages/61/4a/32a002e26025be40cbbd979e77bcc27b6e3de37b26277eade76e82cc1e8b/sqlalchemy-2.0.58-py3-none-any.whl", hash = "sha256:cc1b78ba0ed1f32156d1582f94ca4aca74633e4dcdde3eb1562dd4742493f594", size = 1969678, upload-time = "2026-11-16T20:56:55.932Z" }, ] [package.optional-dependencies] From 096febbd98f8a54c53fe131a65e66397a6ad3229 Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Mon, 30 Nov 2026 20:27:39 +0900 Subject: [PATCH 2/6] Skip the true-division cases whose literal text Athena cannot read (GH-1574) SQLAlchemy 2.0.55 added TrueDivTest.test_truediv_divisor, which divides CAST(literal_column(text) AS NUMERIC(p, s)) values. Athena reads the text 5.02797279921331664759 as DOUBLE, so the quotient is not exactly 7, and rejects the 38-digit integer literal of numeric_38_digit_divisor ("Queries of this type are not supported"). Skip those two operand sets; the other three run. Co-Authored-By: Claude Opus 5.5 --- tests/sqlalchemy/test_suite.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/sqlalchemy/test_suite.py b/tests/sqlalchemy/test_suite.py index f04428a3d..30b121e51 100644 --- a/tests/sqlalchemy/test_suite.py +++ b/tests/sqlalchemy/test_suite.py @@ -1,3 +1,4 @@ +import functools import json as _json import logging from datetime import date @@ -53,6 +54,7 @@ from sqlalchemy.testing.suite import RowFetchTest as _RowFetchTest from sqlalchemy.testing.suite import SameNamedSchemaTableTest as _SameNamedSchemaTableTest from sqlalchemy.testing.suite import SimpleUpdateDeleteTest as _SimpleUpdateDeleteTest +from sqlalchemy.testing.suite import TrueDivTest as _TrueDivTest from sqlalchemy.testing.suite import WindowFunctionTest as _WindowFunctionTest from pyathena.error import OperationalError @@ -1299,3 +1301,19 @@ class SameNamedSchemaTableTest(_InsertFixtureRowsOnce, _SameNamedSchemaTableTest class WindowFunctionTest(_InsertFixtureRowsOnce, _WindowFunctionTest): pass + + +class TrueDivTest(_TrueDivTest): + if hasattr(_TrueDivTest, "test_truediv_divisor"): # SQLAlchemy 2.0.55 and later + # Athena reads the literal text "5.02797279921331664759" as DOUBLE and + # rejects an integer literal outside BIGINT, such as 38 digits. + _RAW_LITERALS_ATHENA_CANNOT_READ = frozenset( + ["5.02797279921331664759", "30000000000000000000000000000000000000"] + ) + + @functools.wraps(_TrueDivTest.test_truediv_divisor) + def test_truediv_divisor(self, **kwargs): + # SQLAlchemy's combinations also pass exclusion arguments. + if kwargs["left"] in self._RAW_LITERALS_ATHENA_CANNOT_READ: + pytest.skip("Athena cannot read this literal_column() text as DECIMAL.") + super().test_truediv_divisor(**kwargs) From ffbabb7447bd8d99a51741cefd906dac285900ef Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Mon, 30 Nov 2026 20:33:44 +0900 Subject: [PATCH 3/6] Assert the CompileError for non-numeric literals and match skipped operand pairs (GH-1574) With the 2.0.52 floor, SQLAlchemy's Numeric and Float literal processors reject a value that is not a number. Assert the CompileError directly, with literal_binds and literal_execute, instead of comparing PyAthena's processors with SQLAlchemy's, which also agreed on 2.0.51 where both wrote the string. State the CompileError in the docs. Match the skipped test_truediv_divisor cases on both operands, so an upstream case with the same dividend still runs. Co-Authored-By: Claude Opus 5.5 --- docs/sqlalchemy.md | 3 ++- tests/pyathena/sqlalchemy/test_types.py | 26 ++++++++++--------------- tests/sqlalchemy/test_suite.py | 10 ++++++++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/sqlalchemy.md b/docs/sqlalchemy.md index 9858209ad..2285a1246 100644 --- a/docs/sqlalchemy.md +++ b/docs/sqlalchemy.md @@ -841,13 +841,14 @@ Athena `FLOAT` and `REAL` are the same 32-bit floating-point type, which keeps a Use `Double` for 64-bit values. `Float(precision)` does not change the Athena type. A value of a floating-point type rendered inline, as with `literal_binds`, `literal_execute`, or in an ARRAY literal, is written with Python's `repr()` for a `float`, which Athena reads as the same `DOUBLE` value, and as `nan()`, `infinity()`, and `-infinity()` for NaN and infinity, also of a `Decimal` or a NumPy value. +A value that is not a real number, such as a string, is written by SQLAlchemy's `Float`, which raises `CompileError` for a value that is not a number. ## Fixed-point types The dialect adapts `Numeric`, `NUMERIC`, and `DECIMAL` to `AthenaNumeric`. A `Decimal` of a fixed-point type rendered inline, as with `literal_binds`, `literal_execute`, or in an ARRAY literal, is written with `decimal_literal()`: a DECIMAL literal with the value's own scale and no exponent, such as `DECIMAL '5.520'` for `Decimal("5.520")` and `DECIMAL '1000'` for `Decimal("1E+3")`. Athena rejects a DECIMAL literal whose precision or scale is above 38, such as the one for `Decimal("1E-39")`, with scale 39, and a NaN or infinity, such as `DECIMAL 'NaN'` or `DECIMAL '-Infinity'`. -A `float` is written as for a floating-point type, and other values, such as an `int`, as SQLAlchemy's `Numeric` writes them. +A `float` is written as for a floating-point type, and other values, such as an `int`, as SQLAlchemy's `Numeric` writes them; it raises `CompileError` for a value that is not a number, such as a string or a NumPy integer. A subclass of `Numeric` other than a floating-point type is adapted to `AthenaNumeric` too, so its own processors, such as `literal_processor()` and `result_processor()`, are not used. To change how a value is processed, subclass `AthenaNumeric`, or use a `TypeDecorator` with a `Numeric` implementation. diff --git a/tests/pyathena/sqlalchemy/test_types.py b/tests/pyathena/sqlalchemy/test_types.py index 9308294f1..b94b262aa 100644 --- a/tests/pyathena/sqlalchemy/test_types.py +++ b/tests/pyathena/sqlalchemy/test_types.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from sqlalchemy import cast, column, literal, select, types +from sqlalchemy import cast, column, exc, literal, select, types from pyathena.sqlalchemy.rest import AthenaRestDialect from pyathena.sqlalchemy.types import AthenaArray @@ -134,21 +134,15 @@ def test_result(self, type_, expected): @pytest.mark.parametrize("type_", [types.Numeric(10, 2), types.Float()]) -def test_other_literal_values_render_as_sqlalchemy(type_): - # A value that is neither a Decimal nor a real number takes SQLAlchemy's own - # literal processor, which checks that the value is a number in 2.0.52 and - # later. - dialect = AthenaRestDialect() - value = "1 OR 1=1" - - def outcome(processor): - try: - return processor(value) - except Exception as e: - return type(e) - - adapted = type_.dialect_impl(dialect).literal_processor(dialect) - assert outcome(adapted) == outcome(type_.literal_processor(dialect)) +@pytest.mark.parametrize( + ("literal_execute", "compile_kwargs"), + [(False, {"literal_binds": True}), (True, {"render_postcompile": True})], +) +def test_non_numeric_literal_raises(type_, literal_execute, compile_kwargs): + # SQLAlchemy's own literal processor checks that the value is a number. + expression = literal("1 OR 1=1", type_, literal_execute=literal_execute) + with pytest.raises(exc.CompileError): + _literal_sql(expression, compile_kwargs) class TestAthenaFloat: diff --git a/tests/sqlalchemy/test_suite.py b/tests/sqlalchemy/test_suite.py index 30b121e51..7eda1f332 100644 --- a/tests/sqlalchemy/test_suite.py +++ b/tests/sqlalchemy/test_suite.py @@ -1308,12 +1308,18 @@ class TrueDivTest(_TrueDivTest): # Athena reads the literal text "5.02797279921331664759" as DOUBLE and # rejects an integer literal outside BIGINT, such as 38 digits. _RAW_LITERALS_ATHENA_CANNOT_READ = frozenset( - ["5.02797279921331664759", "30000000000000000000000000000000000000"] + [ + ("5.02797279921331664759", "0.71828182845904523537"), + ( + "30000000000000000000000000000000000000", + "10000000000000000000000000000000000000", + ), + ] ) @functools.wraps(_TrueDivTest.test_truediv_divisor) def test_truediv_divisor(self, **kwargs): # SQLAlchemy's combinations also pass exclusion arguments. - if kwargs["left"] in self._RAW_LITERALS_ATHENA_CANNOT_READ: + if (kwargs["left"], kwargs["right"]) in self._RAW_LITERALS_ATHENA_CANNOT_READ: pytest.skip("Athena cannot read this literal_column() text as DECIMAL.") super().test_truediv_divisor(**kwargs) From eab1e07f83beb12cb511d686269dc717f7e4841c Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Mon, 30 Nov 2026 20:35:08 +0900 Subject: [PATCH 4/6] Inline the skipped operand pairs of test_truediv_divisor (GH-1574) Co-Authored-By: Claude Opus 5.5 --- tests/sqlalchemy/test_suite.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/sqlalchemy/test_suite.py b/tests/sqlalchemy/test_suite.py index 7eda1f332..6104156ab 100644 --- a/tests/sqlalchemy/test_suite.py +++ b/tests/sqlalchemy/test_suite.py @@ -1305,21 +1305,18 @@ class WindowFunctionTest(_InsertFixtureRowsOnce, _WindowFunctionTest): class TrueDivTest(_TrueDivTest): if hasattr(_TrueDivTest, "test_truediv_divisor"): # SQLAlchemy 2.0.55 and later - # Athena reads the literal text "5.02797279921331664759" as DOUBLE and - # rejects an integer literal outside BIGINT, such as 38 digits. - _RAW_LITERALS_ATHENA_CANNOT_READ = frozenset( - [ + + @functools.wraps(_TrueDivTest.test_truediv_divisor) + def test_truediv_divisor(self, **kwargs): + # SQLAlchemy's combinations also pass exclusion arguments. Athena + # reads the literal text "5.02797279921331664759" as DOUBLE and + # rejects an integer literal outside BIGINT, such as 38 digits. + if (kwargs["left"], kwargs["right"]) in { ("5.02797279921331664759", "0.71828182845904523537"), ( "30000000000000000000000000000000000000", "10000000000000000000000000000000000000", ), - ] - ) - - @functools.wraps(_TrueDivTest.test_truediv_divisor) - def test_truediv_divisor(self, **kwargs): - # SQLAlchemy's combinations also pass exclusion arguments. - if (kwargs["left"], kwargs["right"]) in self._RAW_LITERALS_ATHENA_CANNOT_READ: + }: pytest.skip("Athena cannot read this literal_column() text as DECIMAL.") super().test_truediv_divisor(**kwargs) From 171daf166179a463dfa9010c9718d13cfbc96daf Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Mon, 30 Nov 2026 20:53:01 +0900 Subject: [PATCH 5/6] State which literal values SQLAlchemy rejects and how (GH-1574) SQLAlchemy writes a numeric string such as "1.250" as is and rejects a value that decimal.Decimal() does not read as a number. A literal_execute parameter is rendered when the statement runs, so the rejection reaches the caller as a StatementError wrapping the CompileError. Co-Authored-By: Claude Opus 5.5 --- docs/sqlalchemy.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/sqlalchemy.md b/docs/sqlalchemy.md index 2285a1246..4672ebe57 100644 --- a/docs/sqlalchemy.md +++ b/docs/sqlalchemy.md @@ -841,14 +841,15 @@ Athena `FLOAT` and `REAL` are the same 32-bit floating-point type, which keeps a Use `Double` for 64-bit values. `Float(precision)` does not change the Athena type. A value of a floating-point type rendered inline, as with `literal_binds`, `literal_execute`, or in an ARRAY literal, is written with Python's `repr()` for a `float`, which Athena reads as the same `DOUBLE` value, and as `nan()`, `infinity()`, and `-infinity()` for NaN and infinity, also of a `Decimal` or a NumPy value. -A value that is not a real number, such as a string, is written by SQLAlchemy's `Float`, which raises `CompileError` for a value that is not a number. +A value that is not a real number, such as a string, is written by SQLAlchemy's `Float`, which writes a numeric string such as `"1.250"` as is and rejects a value that `decimal.Decimal()` does not read as a number, such as `"1 OR 1=1"`. ## Fixed-point types The dialect adapts `Numeric`, `NUMERIC`, and `DECIMAL` to `AthenaNumeric`. A `Decimal` of a fixed-point type rendered inline, as with `literal_binds`, `literal_execute`, or in an ARRAY literal, is written with `decimal_literal()`: a DECIMAL literal with the value's own scale and no exponent, such as `DECIMAL '5.520'` for `Decimal("5.520")` and `DECIMAL '1000'` for `Decimal("1E+3")`. Athena rejects a DECIMAL literal whose precision or scale is above 38, such as the one for `Decimal("1E-39")`, with scale 39, and a NaN or infinity, such as `DECIMAL 'NaN'` or `DECIMAL '-Infinity'`. -A `float` is written as for a floating-point type, and other values, such as an `int`, as SQLAlchemy's `Numeric` writes them; it raises `CompileError` for a value that is not a number, such as a string or a NumPy integer. +A `float` is written as for a floating-point type, and other values, such as an `int` or a numeric string, as SQLAlchemy's `Numeric` writes them; it rejects a value that `decimal.Decimal()` does not read as a number, such as `"1 OR 1=1"` or a NumPy integer. +SQLAlchemy raises such a rejection as `CompileError` when the statement is compiled, and, for a `literal_execute` parameter, as a `StatementError` whose `orig` is the `CompileError` when the statement is executed. A subclass of `Numeric` other than a floating-point type is adapted to `AthenaNumeric` too, so its own processors, such as `literal_processor()` and `result_processor()`, are not used. To change how a value is processed, subclass `AthenaNumeric`, or use a `TypeDecorator` with a `Numeric` implementation. From 06fcc379180b04237e8edabec2ae745dbd1d51b3 Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Mon, 30 Nov 2026 20:57:56 +0900 Subject: [PATCH 6/6] Name the decimal.Decimal() rule in the literal docs (GH-1574) Co-Authored-By: Claude Opus 5.5 --- docs/sqlalchemy.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sqlalchemy.md b/docs/sqlalchemy.md index 4672ebe57..b307b6a1e 100644 --- a/docs/sqlalchemy.md +++ b/docs/sqlalchemy.md @@ -841,14 +841,14 @@ Athena `FLOAT` and `REAL` are the same 32-bit floating-point type, which keeps a Use `Double` for 64-bit values. `Float(precision)` does not change the Athena type. A value of a floating-point type rendered inline, as with `literal_binds`, `literal_execute`, or in an ARRAY literal, is written with Python's `repr()` for a `float`, which Athena reads as the same `DOUBLE` value, and as `nan()`, `infinity()`, and `-infinity()` for NaN and infinity, also of a `Decimal` or a NumPy value. -A value that is not a real number, such as a string, is written by SQLAlchemy's `Float`, which writes a numeric string such as `"1.250"` as is and rejects a value that `decimal.Decimal()` does not read as a number, such as `"1 OR 1=1"`. +A value that is not a real number, such as a string, is written by SQLAlchemy's `Float`, which writes a numeric string such as `"1.250"` as is and rejects a value for which `decimal.Decimal(value)` raises, such as `"1 OR 1=1"`. ## Fixed-point types The dialect adapts `Numeric`, `NUMERIC`, and `DECIMAL` to `AthenaNumeric`. A `Decimal` of a fixed-point type rendered inline, as with `literal_binds`, `literal_execute`, or in an ARRAY literal, is written with `decimal_literal()`: a DECIMAL literal with the value's own scale and no exponent, such as `DECIMAL '5.520'` for `Decimal("5.520")` and `DECIMAL '1000'` for `Decimal("1E+3")`. Athena rejects a DECIMAL literal whose precision or scale is above 38, such as the one for `Decimal("1E-39")`, with scale 39, and a NaN or infinity, such as `DECIMAL 'NaN'` or `DECIMAL '-Infinity'`. -A `float` is written as for a floating-point type, and other values, such as an `int` or a numeric string, as SQLAlchemy's `Numeric` writes them; it rejects a value that `decimal.Decimal()` does not read as a number, such as `"1 OR 1=1"` or a NumPy integer. +A `float` is written as for a floating-point type, and other values, such as an `int` or a numeric string, as SQLAlchemy's `Numeric` writes them; it rejects a value for which `decimal.Decimal(value)` raises, such as `"1 OR 1=1"` or a NumPy integer. SQLAlchemy raises such a rejection as `CompileError` when the statement is compiled, and, for a `literal_execute` parameter, as a `StatementError` whose `orig` is the `CompileError` when the statement is executed. A subclass of `Numeric` other than a floating-point type is adapted to `AthenaNumeric` too, so its own processors, such as `literal_processor()` and `result_processor()`, are not used.