Commit Graph
22 Commits
Author SHA1 Message Date
Claude Code 9ae1de960c experiment: fix Presto/Trino TIMESTAMP/DATE literal rendering under SQLAlchemy 2.0
Root cause of the where_latest_partition CompileError across hive/
presto/trino tests ("Could not render literal value '2023-05-01' with
datatype TIMESTAMP"): superset/models/sql_types/presto_sql_types.py's
TimeStamp/Date TypeDecorator subclasses only override process_bind_param,
which returns the *final* literal SQL text ("TIMESTAMP '2023-05-01'") -
Presto/Trino don't support parameter binding for these types, so
process_bind_param has always done double duty as the literal-rendering
hook too.

TypeDecorator.literal_processor()'s standard composition, when only
process_bind_param is overridden (no process_literal_param), pipes its
output through the *impl* type's own literal_processor - i.e. it takes
the string "TIMESTAMP '2023-05-01'" and still runs it through the real
TIMESTAMP type's literal processor, which expects an actual datetime
and calls .isoformat() on it. That blows up with a CompileError. This
composition happens for the process_bind_param fallback path
regardless of whether SQLAlchemy 1.4 or 2.0 - confirmed empirically
that overriding process_literal_param instead doesn't help either,
since TypeDecorator's own literal_processor() chains *both* paths
through the impl processor when the impl has one.

Fixed by overriding literal_processor() directly on both classes -
against TypeDecorator's own docstring advice ("should not implement
this method"), but correct here since process_bind_param already
returns final SQL text rather than a value for further impl
processing to convert.

Separately, hive_tests.py/presto_tests.py hardcoded the expected
compiled SQL for an empty-column select() with two spaces before the
newline ("SELECT  \n"); SQLAlchemy 2.0 renders it with one ("SELECT
\n") - a cosmetic Core-compiler change, fixed the expected strings to
match.

Verified locally (sqlite): tests/integration_tests/db_engine_specs/
and tests/unit_tests/db_engine_specs/ where_latest_partition tests
(hive, presto, trino, both integration and unit) all pass.
2026-08-10 04:39:58 -07:00
Hans Yu 68ebc22e1e refactor: replace Engine.execute() with Connection.execute() (#41917) 2026-07-13 09:40:33 -07:00
Hans Yu c49391ab08 refactor: update Connection.execute() to use queries with text() (#40277) 2026-06-22 15:36:15 -07:00
Beto Dealmeida a26e1d822a chore: remove sqlparse (#33564) 2025-06-04 19:31:41 -04:00
Beto Dealmeida 8de58b9848 feat: use sqlglot to set limit (#33473) 2025-05-27 15:20:02 -04:00
Maxime BeaucheminandElizabeth Thompson e51b95ffa8 chore: enforce more ruff rules (#31447)
Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
2024-12-18 17:41:34 -08:00
Maxime Beauchemin 529aed5da1 chore(deps): cap async_timeout<5.0.0 (#31170) 2024-11-26 14:12:04 -08:00
Beto Dealmeida 09802acf0d refactor: remove more sqlparse (#31032) 2024-11-26 17:01:07 -05:00
Maxime Beauchemin fd9d3301f6 chore: deprecate tox in favor of act (#29382) 2024-11-26 13:27:37 -08:00
c5f6cc6382 chore(🦾): bump python et-xmlfile 1.1.0 -> 2.0.0 & remove pyhive[hive] from requirements/development.in (#31040)
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Maxime Beauchemin <maximebeauchemin@gmail.com>
2024-11-24 13:35:50 -08:00
Beto Dealmeida 6cf681df68 feat(SIP-95): new endpoint for table metadata (#28122) 2024-04-25 12:23:49 -04:00
Maxime Beauchemin 2d63722150 chore: set up ruff as a new linter/formatter (#28158) 2024-04-24 17:19:53 -07:00
Beto Dealmeida 99a1601aea refactor: rename get_sqla_engine_with_context (#28012) 2024-04-12 13:31:05 -04:00
John Bodley 847ed3f5b0 refactor: Ensure Flask framework leverages the Flask-SQLAlchemy session (Phase II) (#26909) 2024-02-14 06:20:15 +13:00
John Bodley a4d5d7c6b9 chore(pre-commit): Add pyupgrade and pycln hooks (#24197) 2023-06-01 12:01:10 -07:00
Ville Brofeldt cd6fc35f60 chore(db_engine_specs): clean up column spec logic and add tests (#22871) 2023-01-31 15:54:07 +02:00
John Bodley 0b31b2cb87 fix(hive): Regression in #21794 (#22794) 2023-01-21 13:00:36 +13:00
Hugh A. Miles II e23efefc46 feat: refactor all get_sqla_engine to use contextmanager in codebase (#21943) 2022-11-15 13:45:14 -05:00
John Bodley 9f7bd1e63f fix(presto/trino): Ensure get_table_names only returns real tables (#21794) 2022-11-09 14:30:49 -08:00
Ville Brofeldt a619cb4ea9 chore: upgrade black (#19410) 2022-03-29 20:03:09 +03:00
Long Le XichandVille Brofeldt bc855f4040 fix(hive): Update _latest_partition_from_df in HiveEngineSpec to work on tables with multiple indexes (#14302)
* Fix _latest_partition_from_df in HiveEngineSpec

* Add test HiveEngineSpec._latest_partition_from_df

* Fix formatting to pass black

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
2021-11-23 10:07:47 +02:00
ofekisr b5119b8dff refactor(tests): decouple unittests from integration tests (#15473)
* refactor move all tests to be under integration_tests package

* refactor decouple unittests from integration tests - commands

* add unit_tests package

* fix celery_tests.py

* fix wrong FIXTURES_DIR value
2021-07-01 18:03:07 +03:00