MCPcopy Create free account
hub / github.com/PostHog/duckgres / handleToTimestamp

Method handleToTimestamp

transpiler/transform/functions.go:488–499  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
488func (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.
502func renameFuncAndStripPrefix(fc *pg_query.FuncCall, funcNameIdx int, newName string) {

Callers 1

handleSpecialFunctionMethod · 0.95

Calls 4

extractStringConstantFunction · 0.85
setStringConstantFunction · 0.85
pgDateFormatToStrftimeFunction · 0.85
renameFuncAndStripPrefixFunction · 0.85

Tested by

no test coverage detected