rusackas commented on code in PR #44546: URL: https://github.com/apache/superset/pull/44546#discussion_r4140444986
########## tests/testcontainers/db_engine_specs/test_bigquery.py: ########## @@ -0,0 +1,151 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +Tests Superset's BigQuery string-literal escaping (superset/db_engine_specs/ +bigquery.py's ``_monkeypatch_bigquery_string_literal``) against a real +GoogleSQL query engine, spun up on demand via testcontainers. Run via +.github/workflows/testcontainers.yml. + +sc-120493-adjacent investigation: an apostrophe in a filter value used to +break BigQuery queries (apache/superset#35857 / #38835, doubled single +quotes -- BigQuery rejects ``'Armando''s'`` as two adjacent string literals +needing whitespace between them). The current fix backslash-escapes instead. +Reasoning about correctness from the ``sqlalchemy-bigquery`` dialect source +and the BigQuery DBAPI's ``pyformat`` paramstyle handling is necessary but +not sufficient; this locks in the actual compiled-and-executed behavior +against a real engine instead. +""" + +from collections.abc import Iterator + +import pytest +import sqlalchemy as sa +from sqlalchemy.engine import Engine + +pytestmark = pytest.mark.testcontainers + +from ._driver import require_driver # noqa: E402 + +require_driver("testcontainers.community.google") + +from google.cloud import bigquery # noqa: E402 +from sqlalchemy_bigquery import BigQueryDialect # noqa: E402 +from testcontainers.community.google import BigQueryContainer # noqa: E402 Review Comment: Dug into this: `BigQueryContainer` isn't in any published testcontainers release, not even the latest (still 4.15.0), or their `main` branch. It's still an open, unmerged PR upstream (testcontainers/testcontainers-python#1121). Vendored a local one in `_bigquery_container.py` instead, same pattern this suite already uses for StarRocks/ClickHouse. Ran it against real Docker, all 4 tests pass. ########## tests/testcontainers/db_engine_specs/test_bigquery.py: ########## @@ -0,0 +1,151 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +Tests Superset's BigQuery string-literal escaping (superset/db_engine_specs/ +bigquery.py's ``_monkeypatch_bigquery_string_literal``) against a real +GoogleSQL query engine, spun up on demand via testcontainers. Run via Review Comment: Added a `bigquery` entry to `testcontainers.yml`'s matrix, plus a note in `development.in` on why it needs no extra of its own. It only actually runs now because of the fix in the thread above; before that it would've hard-failed on import, not skipped. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
