Skip to content

Conversation

@EDsCODE
Copy link
Contributor

@EDsCODE EDsCODE commented Dec 20, 2025

Summary

  • Fix TIME type wire protocol serialization
  • Fix INTERVAL type wire protocol serialization
  • Improve to_char, to_date, to_timestamp macros
  • Use DuckDB native make_time and age functions

Changes

Wire Protocol Fixes (server/conn.go)

  • TIME type: Detect when DuckDB returns time.Time with date 0001-01-01 and output only time portion
  • INTERVAL type: Add duckdb.Interval handling with proper PostgreSQL format
    • Format as "X years Y mons Z days HH:MM:SS"

Macro Fixes (server/catalog.go)

  • to_char: Add Day, Month, Mon format codes for day/month names
  • to_date: Use CASE statement for common date formats (strptime requires constant format)
  • to_timestamp: Use CASE statement for common timestamp formats
  • Removed: make_time and age macros (DuckDB has native functions)

Test Results

Metric Before After Change
Pass 622 636 +14
Fail 99 85 -14
Rate 86.3% 88.2% +1.9%

Remaining DateTime Failure

  • to_char_number: PostgreSQL number formatting not supported (to_char for numbers is a separate feature)

Test plan

  • Run integration tests: go test ./tests/integration/...
  • Verify TIME serialization: SELECT TIME '12:30:45'
  • Verify INTERVAL serialization: SELECT INTERVAL '1 day'
  • Verify to_date: SELECT to_date('2024-06-15', 'YYYY-MM-DD')
  • Verify age function: SELECT age(TIMESTAMP '2024-06-15', TIMESTAMP '2020-01-01')

🤖 Generated with Claude Code

Improve PostgreSQL datetime compatibility in wire protocol and macros:

## Wire Protocol Fixes (server/conn.go)
- Fix TIME type formatting: detect date 0001-01-01 and output time only
- Add duckdb.Interval handling with proper PostgreSQL format
- Format intervals as "X years Y mons Z days HH:MM:SS"

## Macro Fixes (server/catalog.go)
- Fix to_char: add Day, Month, Mon format codes for strftime
- Fix to_date: use CASE for common date formats (strptime requires constant)
- Fix to_timestamp: use CASE for common timestamp formats
- Remove make_time/age macros (DuckDB has native functions)

## Transpiler Fixes (transpiler/transform/pgcatalog.go)
- Remove make_time and age from custom macro list

## Test Results
- Before: 622/721 subtests passing (86.3%)
- After: 636/721 subtests passing (88.2%)
- Improvement: +14 tests passing

Remaining DateTime failure:
- to_char_number: PostgreSQL number formatting not supported

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@EDsCODE EDsCODE marked this pull request as draft December 20, 2025 00:47
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.

2 participants