#16470·dbt-core

[v2 Bug] DuckDB unit test fixtures cast TIMESTAMP WITH TIME ZONE columns as `timestamp without time zone`, shifting values by the session timezone

Author: luc-pimentelCreated Sep 25, 2026Updated Oct 1, 2026

Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?

  • I believe this is a new bug in dbt v2.x
  • I have searched the existing issues and could not find a duplicate

Current Behavior

For a model column of type TIMESTAMP WITH TIME ZONE, the expect fixture value is cast as timestamp without time zone in the generated unit test SQL (target/compiled/<project>/models/<test>.sql):

sql
CAST('2024-01-01 00:00:00+00' AS timestamp without time zone) AS ts_tz

The +00 offset is dropped, and the UNION ALL with the actual column re-interprets the value in the session timezone. With TimeZone = America/Sao_Paulo, expected renders as 2024-01-01T00:00:00-03:00 while actual is 2023-12-31T21:00:00-03:00, so a correct expectation is three hours off. With TZ=UTC the same test passes.

Today this is masked by #15894 (timestamp columns are never compared, both sides render as [unsupported]). Once that is fixed, correct tz-aware expectations fail on DuckDB outside UTC.

Expected Behavior

The fixture should be cast to the column's actual type (timestamp with time zone) so '2024-01-01 00:00:00+00' keeps its offset and matches the model output in any session timezone. This is what dbt-core 1.12.5 with dbt-duckdb generates:

sql
cast('2024-01-01 00:00:00+00' as TIMESTAMP WITH TIME ZONE)

Steps To Reproduce

  1. models/ts_model.sql:
    sql
    select timestamptz '2024-01-01 00:00:00+00' as ts_tz
  2. models/ts_model.yml:
    yaml
    unit_tests:
      - name: tz_fixture_matches
        model: ts_model
        given: []
        expect:
          rows:
            - {ts_tz: "2024-01-01 00:00:00+00"}
  3. DuckDB profile, session timezone other than UTC (for example TZ=America/Sao_Paulo dbt build).
  4. Inspect target/compiled/<project>/models/tz_fixture_matches.sql: the expected CTE casts ts_tz as timestamp without time zone.
  5. Re-run with TZ=UTC dbt build and compare.

Relevant log output

With the comparison fix from #15894 applied locally, the diff table shows:

| ts_tz                                                  |
| 2024-01-01T00:00:00-03:00 -> 2023-12-31T21:00:00-03:00 |

Environment

  • OS: macOS
  • CPU: ARM
  • dbt distribution and version: dbt 2.0.6 (Core); OSS build from main at 7e4e937c4 for the diff output. Compared against dbt-core 1.12.5 + dbt-duckdb 1.11.0, where the same test passes.

Which database adapter are you using?

duckdb

Is this a discrepancy vs. dbt 1.x?

  • Yes — this works in dbt 1.x but not in dbt v2.x

Additional Context

Cause: the type formatter in crates/dbt-adapter/src/sql_types.rs renders every DataType::Timestamp(_, _) as timestamp without time zone, ignoring the timezone on the Arrow type. Found while working on #15894; that fix does not change fixture typing.