Trino version
483
Please describe the bug
Trino incorrectly returns zero rows when a timestamp(9) is cast to timestamp(6) with time zone inside a filter.
Reproduction
SELECT count(*) FROM ( VALUES CAST( TIMESTAMP '2026-07-26 03:00:00' AS timestamp(9) ) ) t(lastupdate) WHERE CAST(lastupdate AS timestamp(6) WITH TIME ZONE) > TIMESTAMP '2026-07-25 00:00:00 UTC';
Expected result: 1 (The timestamp is later than the value used in the filter.)
Actual result: 0
EXPLAIN shows that Trino removes the input during planning:
Trino version: 483
Fragment 0 [SINGLE]
Output layout: [count]
Output partitioning: SINGLE []
Output[columnNames = [_col0]]
│ Layout: [count:bigint]
│ Estimates: {rows: 1 (9B), cpu: 0, memory: 0B, network: 0B}
│ _col0 := count
└─ Aggregate[]
│ Layout: [count:bigint]
│ Estimates: {rows: 1 (9B), cpu: 0, memory: 9B, network: 0B}
│ count := count(*)
└─ Values[]
Layout: []
Estimates: {rows: 0 (0B), cpu: 0, memory: 0B, network: 0B}
Working variants
SELECT count(*) FROM ( VALUES CAST( TIMESTAMP '2026-07-26 03:00:00' AS timestamp(9) ) ) t(lastupdate) WHERE CAST(lastupdate AS timestamp(9) WITH TIME ZONE) > CAST( TIMESTAMP '2026-07-25 00:00:00 UTC' AS timestamp(9) WITH TIME ZONE );
or
SELECT count(*) FROM ( VALUES CAST( TIMESTAMP '2026-07-26 03:00:00' AS timestamp(9) ) ) t(lastupdate) WHERE with_timezone(lastupdate, 'Europe/Zurich') > TIMESTAMP '2026-07-25 00:00:00 UTC';
The problem seems to occur specifically when the cast reduces the precision from timestamp(9) to timestamp(6).
Trino version
483
Please describe the bug
Trino incorrectly returns zero rows when a timestamp(9) is cast to timestamp(6) with time zone inside a filter.
Reproduction
Expected result: 1 (The timestamp is later than the value used in the filter.)
Actual result: 0
EXPLAIN shows that Trino removes the input during planning:
Working variants
or
The problem seems to occur specifically when the cast reduces the precision from
timestamp(9)totimestamp(6).