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

Method handleToDate

transpiler/transform/functions.go:474–484  ·  view source on GitHub ↗

handleToDate converts PostgreSQL to_date(text, format) to strptime with converted format.

(fc *pg_query.FuncCall, funcNameIdx int)

Source from the content-addressed store, hash-verified

472
473// handleToDate converts PostgreSQL to_date(text, format) to strptime with converted format.
474func (t *FunctionTransform) handleToDate(fc *pg_query.FuncCall, funcNameIdx int) bool {
475 if len(fc.Args) != 2 {
476 return false
477 }
478 formatStr := extractStringConstant(fc.Args[1])
479 if formatStr != "" {
480 setStringConstant(fc.Args[1], pgDateFormatToStrftime(formatStr))
481 }
482 renameFuncAndStripPrefix(fc, funcNameIdx, "strptime")
483 return true
484}
485
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).

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