Skip to content

BigQuery→DuckDB: DATE(timestamp, time_zone) emitted as STRPTIME(timestamp, time_zone) #476

Description

@nikchha

DATE(timestamp_expression, time_zone) is transpiled to STRPTIME(...), treating the time zone as a format string.

Version: @polyglot-sql/sdk 0.12.1, DuckDB 1.5.5

Repro

import { transpile, Dialect } from '@polyglot-sql/sdk';

transpile(
  "SELECT DATE(TIMESTAMP '2026-01-31 23:30:00+00', 'Europe/Berlin') AS d",
  Dialect.BigQuery,
  Dialect.DuckDB,
).sql[0];

Actual

SELECT CAST(STRPTIME(CAST('2026-01-31 23:30:00+00' AS TIMESTAMPTZ), 'Europe/Berlin') AS DATE) AS d

DuckDB: Binder Error: No function matches the given name and argument types 'strptime(TIMESTAMP WITH TIME ZONE, STRING_LITERAL)'

Expected

The two-argument form converts the timestamp to the given time zone before taking the date. BigQuery returns 2026-02-01. For reference, sqlglot emits:

SELECT CAST(CAST(CAST('2026-01-31 23:30:00+00' AS TIMESTAMPTZ) AS TIMESTAMP) AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Berlin' AS DATE) AS d

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions