Files
superset2/tests/unit_tests/db_engine_specs
Claude Code 73ca8fb727 fix(db-engine-specs): handle bare-year python_date_format columns in time-grain expressions
get_timestamp_expr() only knew how to convert epoch_s/epoch_ms raw values
into a proper timestamp before applying a time-grain truncation function;
any other python_date_format (e.g. "%Y") fell through and passed the raw
value straight into the grain function. On SQLite that means
DATETIME(year, 'start of year') interprets a bare integer year as a Julian
day number rather than a calendar year, silently returning NULL for every
row. This exact pattern ships in Superset's own video_game_sales example
dataset (year: BIGINT, is_dttm=true, python_date_format: '%Y'), so any
time-grain-truncated chart against it (Nightingale Rose included) returns
no data.

Add a year_to_dttm() hook (mirroring epoch_to_dttm/epoch_ms_to_dttm) that
converts a bare year into a proper date before truncation, implemented for
SQLite via printf()-based date construction with an explicit NULL guard
(printf() otherwise treats a NULL argument as 0).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 23:30:57 -07:00
..