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

Method Transform

transpiler/transform/functions.go:169–202  ·  view source on GitHub ↗
(tree *pg_query.ParseResult, result *Result)

Source from the content-addressed store, hash-verified

167}
168
169func (t *FunctionTransform) Transform(tree *pg_query.ParseResult, result *Result) (bool, error) {
170 changed := false
171
172 WalkFunc(tree, func(node *pg_query.Node) bool {
173 if svf := node.GetSqlvalueFunction(); svf != nil {
174 if t.transformSQLValueFunction(svf) {
175 changed = true
176 }
177 return true
178 }
179 if fc := node.GetFuncCall(); fc != nil {
180 // 2-arg log(base, value) -> ln(value) / ln(base)
181 // Must happen here because it replaces the FuncCall node with an A_Expr
182 if t.isLogTwoArg(fc) {
183 t.replaceLogWithLnDivision(node, fc)
184 changed = true
185 return true
186 }
187 // Compat rewrites that replace the whole FuncCall node (format, 3-arg
188 // date_trunc, overlay, isfinite-interval) must run here, where node is
189 // available. See functions_compat.go.
190 if t.replaceCompatFuncNode(node, fc) {
191 changed = true
192 return true
193 }
194 if t.transformFuncCall(fc) {
195 changed = true
196 }
197 }
198 return true
199 })
200
201 return changed, nil
202}
203
204// transformSQLValueFunction rewrites the precision forms LOCALTIME(p),
205// LOCALTIMESTAMP(p), CURRENT_TIME(p) and CURRENT_TIMESTAMP(p) to their bare

Callers

nothing calls this directly

Calls 6

isLogTwoArgMethod · 0.95
replaceCompatFuncNodeMethod · 0.95
transformFuncCallMethod · 0.95
WalkFuncFunction · 0.85

Tested by

no test coverage detected