Skip to content

PostgreSQL TIMESTAMPTZ schema mismatch: builder lacks timezone #70

@zfarrell

Description

@zfarrell

Summary

When fetching PostgreSQL TIMESTAMPTZ columns, the Arrow schema declares Timestamp(Microsecond, Some("UTC")) but the actual data is created with Timestamp(Microsecond, None), causing a schema mismatch error.

Root Cause

In src/datafetch/native/postgres.rs:

  1. pg_type_to_arrow("timestamptz") correctly returns DataType::Timestamp(Microsecond, Some("UTC"))
  2. However, make_builder() at line ~372 creates the builder without timezone info:
    DataType::Timestamp(_, _) => Box::new(TimestampMicrosecondBuilder::with_capacity(capacity)),

The TimestampMicrosecondBuilder creates arrays with None timezone by default.

Fix

Use TimestampMicrosecondBuilder::with_capacity(capacity).with_timezone_opt(tz.clone()) to preserve the timezone from the schema.

Discovered By

Type coverage tests in tests/type_coverage/postgres_types.rs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions