handleToTimestamp converts 2-arg PostgreSQL to_timestamp(text, format) to strptime. 1-arg to_timestamp(epoch) is left unchanged (DuckDB handles it natively).
(fc *pg_query.FuncCall, funcNameIdx int)
| 486 | // handleToTimestamp converts 2-arg PostgreSQL to_timestamp(text, format) to strptime. |
| 487 | // 1-arg to_timestamp(epoch) is left unchanged (DuckDB handles it natively). |
| 488 | func (t *FunctionTransform) handleToTimestamp(fc *pg_query.FuncCall, funcNameIdx int) bool { |
| 489 | if len(fc.Args) != 2 { |
| 490 | // 1-arg form: to_timestamp(epoch) — DuckDB handles natively |
| 491 | return false |
| 492 | } |
| 493 | formatStr := extractStringConstant(fc.Args[1]) |
| 494 | if formatStr != "" { |
| 495 | setStringConstant(fc.Args[1], pgDateFormatToStrftime(formatStr)) |
| 496 | } |
| 497 | renameFuncAndStripPrefix(fc, funcNameIdx, "strptime") |
| 498 | return true |
| 499 | } |
| 500 | |
| 501 | // renameFuncAndStripPrefix renames a function and removes any pg_catalog/public schema prefix. |
| 502 | func renameFuncAndStripPrefix(fc *pg_query.FuncCall, funcNameIdx int, newName string) { |
no test coverage detected