From 210268117416d9b265ab790ab4287fee28da4ec7 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Mon, 20 Jul 2026 08:38:38 +0000 Subject: [PATCH 1/6] fix(sqlalchemy-bigquery): resolve ST function type binding bug and unskip geography tests --- .../sqlalchemy_bigquery/geography.py | 5 ++- .../tests/unit/test_geography.py | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/sqlalchemy-bigquery/sqlalchemy_bigquery/geography.py b/packages/sqlalchemy-bigquery/sqlalchemy_bigquery/geography.py index 670fc576b2e2..744bfc803c70 100644 --- a/packages/sqlalchemy-bigquery/sqlalchemy_bigquery/geography.py +++ b/packages/sqlalchemy-bigquery/sqlalchemy_bigquery/geography.py @@ -183,9 +183,8 @@ def _fixup_st_arguments(element, compiler, **kw): argument_types = _argument_types.get(element.name.lower()) if argument_types: for argument_type, argument in zip(argument_types, element.clauses.clauses): - if isinstance(argument, BindParameter) and ( - argument.type is not argument_type - or not isinstance(argument.type, argument_type) + if isinstance(argument, BindParameter) and not isinstance( + argument.type, argument_type ): argument.type = argument_type() diff --git a/packages/sqlalchemy-bigquery/tests/unit/test_geography.py b/packages/sqlalchemy-bigquery/tests/unit/test_geography.py index d03dbf940d93..5a24fc77286d 100644 --- a/packages/sqlalchemy-bigquery/tests/unit/test_geography.py +++ b/packages/sqlalchemy-bigquery/tests/unit/test_geography.py @@ -24,8 +24,6 @@ geoalchemy2 = pytest.importorskip("geoalchemy2") -# TODO(http://github.com/googleapis/google-cloud-python/issues/17287): Unskip once bug is resolved. -@pytest.mark.skip(reason="Failing in CI with AssertionError.") def test_geoalchemy2_core(faux_conn, last_query): """Make sure GeoAlchemy 2 Core Tutorial works as adapted to only having geometry""" conn = faux_conn @@ -101,7 +99,7 @@ def test_geoalchemy2_core(faux_conn, last_query): last_query( "SELECT `lake`.`name` \n" "FROM `lake` \n" - "WHERE ST_Contains(`lake`.`geog`, %(ST_Contains_1:geography)s)", + "WHERE ST_Contains(`lake`.`geog`, %(ST_Contains_1:STRING)s)", {"ST_Contains_1": "POINT(4 1)"}, ) @@ -183,3 +181,30 @@ def test_calling_st_functions_that_dont_take_geographies(faux_conn, last_query): " AS `ST_GeogFromText_1`", dict(ST_GeogFromText_2="point(0 0)"), ) + + +def test_fixup_st_arguments(): + from sqlalchemy_bigquery.geography import _fixup_st_arguments, GEOGRAPHY + from geoalchemy2.functions import ST_Area, GenericFunction + from sqlalchemy.sql.elements import BindParameter + + class DummyCompiler: + def visit_function(self, element, **kw): + return "func(param)" + + # Case 1: argument.type is not yet GEOGRAPHY + func_element = ST_Area(BindParameter("param", "point(0 0)")) + res = _fixup_st_arguments(func_element, DummyCompiler()) + assert res == "func(param)" + assert isinstance(func_element.clauses.clauses[0].type, GEOGRAPHY) + + # Case 2: argument.type is ALREADY GEOGRAPHY + func_element2 = ST_Area(BindParameter("param", "point(0 0)", type_=GEOGRAPHY())) + _fixup_st_arguments(func_element2, DummyCompiler()) + + # Case 3: function without specified argument types + class ST_Unknown(GenericFunction): + name = "ST_Unknown" + + func_element3 = ST_Unknown(BindParameter("param", "point(0 0)")) + _fixup_st_arguments(func_element3, DummyCompiler()) From 5f11a2e507ddef5827a2fe3c90ddb19b5932a320 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Mon, 20 Jul 2026 08:50:17 +0000 Subject: [PATCH 2/6] chore(sqlalchemy-bigquery): restore fail_under=100 in .coveragerc and noxfile --- packages/sqlalchemy-bigquery/.coveragerc | 5 +++-- packages/sqlalchemy-bigquery/noxfile.py | 2 +- packages/sqlalchemy-bigquery/tests/unit/test_engine.py | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/sqlalchemy-bigquery/.coveragerc b/packages/sqlalchemy-bigquery/.coveragerc index 73bf56dd1535..ade37d3d7eb6 100644 --- a/packages/sqlalchemy-bigquery/.coveragerc +++ b/packages/sqlalchemy-bigquery/.coveragerc @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Generated by synthtool. DO NOT EDIT! [run] branch = True omit = @@ -22,7 +21,7 @@ omit = sqlalchemy_bigquery/requirements.py [report] -fail_under = 98 +fail_under = 100 show_missing = True exclude_lines = # Re-enable the standard pragma @@ -37,3 +36,5 @@ omit = */core/*.py */site-packages/*.py sqlalchemy_bigquery/requirements.py + tests/* + */tests/* diff --git a/packages/sqlalchemy-bigquery/noxfile.py b/packages/sqlalchemy-bigquery/noxfile.py index b1e6b068c872..2e171cc31444 100644 --- a/packages/sqlalchemy-bigquery/noxfile.py +++ b/packages/sqlalchemy-bigquery/noxfile.py @@ -467,7 +467,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing") + session.run("coverage", "report", "--show-missing", "--fail-under=100") session.run("coverage", "erase") diff --git a/packages/sqlalchemy-bigquery/tests/unit/test_engine.py b/packages/sqlalchemy-bigquery/tests/unit/test_engine.py index 67265b5ab853..4825fa6fc4fb 100644 --- a/packages/sqlalchemy-bigquery/tests/unit/test_engine.py +++ b/packages/sqlalchemy-bigquery/tests/unit/test_engine.py @@ -70,3 +70,10 @@ def test_arraysize_querystring_takes_precedence_over_default(faux_conn, metadata metadata.create_all(engine) assert conn.connection.test_data["arraysize"] == arraysize + + +def test_dbapi_deprecated(): + from sqlalchemy_bigquery.base import BigQueryDialect + + assert BigQueryDialect.dbapi() is BigQueryDialect.import_dbapi() + From 30dbeb1621e849a61561ff0bd8c97fe94385a450 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Mon, 20 Jul 2026 09:27:48 +0000 Subject: [PATCH 3/6] chore(sqlalchemy-bigquery): remove redundant --fail-under=100 from cover session in noxfile --- packages/sqlalchemy-bigquery/noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sqlalchemy-bigquery/noxfile.py b/packages/sqlalchemy-bigquery/noxfile.py index 2e171cc31444..b1e6b068c872 100644 --- a/packages/sqlalchemy-bigquery/noxfile.py +++ b/packages/sqlalchemy-bigquery/noxfile.py @@ -467,7 +467,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") + session.run("coverage", "report", "--show-missing") session.run("coverage", "erase") From f9450907f6660f2dab8b00597f0832989d7d0dd9 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Tue, 21 Jul 2026 18:40:58 +0000 Subject: [PATCH 4/6] style(sqlalchemy-bigquery): format test_geography.py with black --- packages/sqlalchemy-bigquery/tests/unit/test_geography.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sqlalchemy-bigquery/tests/unit/test_geography.py b/packages/sqlalchemy-bigquery/tests/unit/test_geography.py index ccbf0abc1f4c..332cb1c3a954 100644 --- a/packages/sqlalchemy-bigquery/tests/unit/test_geography.py +++ b/packages/sqlalchemy-bigquery/tests/unit/test_geography.py @@ -188,6 +188,7 @@ def test_fixup_st_arguments(): from sqlalchemy.sql.elements import BindParameter from sqlalchemy_bigquery.geography import GEOGRAPHY, _fixup_st_arguments + class DummyCompiler: def visit_function(self, element, **kw): return "func(param)" From f9db540bd4a288c31c0014fbfec8e5688cbd057c Mon Sep 17 00:00:00 2001 From: ohmayr Date: Tue, 21 Jul 2026 18:44:13 +0000 Subject: [PATCH 5/6] style(sqlalchemy-bigquery): format test_engine.py with black --- packages/sqlalchemy-bigquery/tests/unit/test_engine.py | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sqlalchemy-bigquery/tests/unit/test_engine.py b/packages/sqlalchemy-bigquery/tests/unit/test_engine.py index 4825fa6fc4fb..7362ab588425 100644 --- a/packages/sqlalchemy-bigquery/tests/unit/test_engine.py +++ b/packages/sqlalchemy-bigquery/tests/unit/test_engine.py @@ -76,4 +76,3 @@ def test_dbapi_deprecated(): from sqlalchemy_bigquery.base import BigQueryDialect assert BigQueryDialect.dbapi() is BigQueryDialect.import_dbapi() - From 66be0a3e220b2b47468247de7af57c03f6f951c6 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Tue, 21 Jul 2026 18:45:47 +0000 Subject: [PATCH 6/6] chore(sqlalchemy-bigquery): restore Generated by synthtool comment in .coveragerc --- packages/sqlalchemy-bigquery/.coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sqlalchemy-bigquery/.coveragerc b/packages/sqlalchemy-bigquery/.coveragerc index ade37d3d7eb6..7b0d6b3cd7dc 100644 --- a/packages/sqlalchemy-bigquery/.coveragerc +++ b/packages/sqlalchemy-bigquery/.coveragerc @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Generated by synthtool. DO NOT EDIT! [run] branch = True omit =