Skip to content

fix: DuckDB TIMESTAMPTZ and TIMETZ columns displaying as null (#424)#427

Merged
datlechin merged 2 commits intomainfrom
fix/duckdb-timestamptz-424
Mar 22, 2026
Merged

fix: DuckDB TIMESTAMPTZ and TIMETZ columns displaying as null (#424)#427
datlechin merged 2 commits intomainfrom
fix/duckdb-timestamptz-424

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

@datlechin datlechin commented Mar 22, 2026

Summary

  • Fix TIMESTAMPTZ and TIMETZ columns showing as null in DuckDB plugin
  • Add missing type names: TIMESTAMPTZ, TIMETZ, TIME_NS, UHUGEINT, ARRAY
  • Add type-specific fallback extraction when duckdb_value_varchar returns nil
  • Re-query with SQL CAST for TZ types where no C API extraction works (DuckDB v1.5.0 limitation)

Root cause

DuckDB v1.5.0 C API duckdb_value_varchar() returns NULL for TIMESTAMPTZ and TIMETZ columns. duckdb_value_is_null() is also unreliable for these types. The deprecated duckdb_column_data() works for TIMESTAMPTZ but not TIMETZ.

Approach

  • TIMESTAMPTZ/TIMETZ: Re-execute query with CASE WHEN col IS NULL THEN NULL ELSE CAST(col AS VARCHAR) END for TZ columns, then patch results
  • Other fallback types: Type-specific extraction via duckdb_value_timestamp, duckdb_value_int*, etc.
  • Missing type names: Added 5 missing DuckDB type constants to typeName(for:)

Closes #424

Test plan

  • Build succeeds
  • Lint clean (0 violations)
  • Manual: DuckDB SELECT '2026-03-22T12:00:00Z'::timestamptz AS tm shows timestamp value
  • Manual: DuckDB SELECT '12:00:00+05:30'::timetz AS t shows time with offset
  • Manual: NULL TIMESTAMPTZ/TIMETZ values display as NULL (not garbage)
  • Manual: Non-TZ types (DATE, TIME, TIMESTAMP, VARCHAR, INTEGER) still work

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where certain temporal column types were incorrectly displayed as null values in DuckDB queries. These columns now properly return their actual values.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 22, 2026

Warning

Rate limit exceeded

@datlechin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f5371e54-4c96-45b8-a01a-ef2e2e05b596

📥 Commits

Reviewing files that changed from the base of the PR and between 63b8873 and caeaa5d.

📒 Files selected for processing (1)
  • Plugins/DuckDBDriverPlugin/DuckDBPlugin.swift
📝 Walkthrough

Walkthrough

The DuckDB plugin was updated to fix temporal columns (TIMESTAMPTZ, TIMETZ, etc.) displaying as null. Changes include post-processing query results with a TZ column patcher, implementing fallback type conversions when varchar extraction fails, and extending type name recognition for additional DuckDB temporal and numeric types.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added fix entry documenting DuckDB update preventing temporal columns from displaying as null.
DuckDB Plugin Core Logic
Plugins/DuckDBDriverPlugin/DuckDBPlugin.swift
Implemented post-processing via patchTzColumns to handle TIMESTAMPTZ/TIMETZ columns; enhanced extractResult to track column types and use fallback conversions; extended type name recognition; added helpers for formatted extraction of timestamps, times, booleans, and integers; changed DuckDBRawResult.rows to mutable for in-place patching.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Timestamps were lost in the void so deep,
TZ columns slumbered, null in their sleep,
But now with a patch and conversions so bright,
Temporal values hop back into sight! 🕐✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main fix: addressing TIMESTAMPTZ and TIMETZ columns displaying as null in DuckDB, matching the core objective of the PR.
Linked Issues check ✅ Passed The PR implements all required fixes: adds missing DuckDB type names, implements fallback type-specific extraction, and patches TZ columns to resolve the null display issue reported in #424.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing TIMESTAMPTZ/TIMETZ null display: type recognition, fallback extraction, and TZ column patching. No out-of-scope changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/duckdb-timestamptz-424

Comment @coderabbitai help to get the list of available commands and usage tips.

@datlechin datlechin merged commit 1ebf8bf into main Mar 22, 2026
2 checks passed
@datlechin datlechin deleted the fix/duckdb-timestamptz-424 branch March 22, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DuckDB plugin fails to display timestamptz column

1 participant