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

Function jsonFuncReturnsNonJSON

transpiler/transform/operators.go:700–711  ·  view source on GitHub ↗

jsonFuncReturnsNonJSON reports whether a json*-named function returns a non-JSON value (VARCHAR, BIGINT, BOOLEAN, ...), so its result concatenated with || must keep DuckDB string-concat semantics. Covers both the PostgreSQL names and the DuckDB names FunctionTransform rewrites them to (function mapp

(name string)

Source from the content-addressed store, hash-verified

698// names and the DuckDB names FunctionTransform rewrites them to (function
699// mapping runs before this transform in the pipeline).
700func jsonFuncReturnsNonJSON(name string) bool {
701 for _, suffix := range []string{"_string", "_text", "_length", "_keys", "_valid", "_exists", "_contains"} {
702 if strings.HasSuffix(name, suffix) {
703 return true
704 }
705 }
706 switch name {
707 case "json_type", "json_typeof", "jsonb_typeof":
708 return true
709 }
710 return false
711}
712
713// createJSONConcatExpr rewrites `a || b` (with a JSON-looking operand) to a
714// CASE expression reproducing Postgres jsonb || semantics in DuckDB:

Callers 1

looksJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected