feat: Add clp_get_json_string UDF.#82
Conversation
WalkthroughAdds a new scalar function CLP_GET_JSON_STRING to the Presto CLP plugin, updates the CLP UDF rewriter to handle this function specially within ProjectNode contexts by emitting a placeholder variable and synthetic column mapping, and updates/renames tests; also updates a Velox submodule commit hash. Changes
Sequence DiagramsequenceDiagram
participant Q as QueryPlanner
participant R as ClpUdfRewriter
participant P as ProjectNode
participant T as TableScanNode
Q->>R: rewriteClpUdfs(planRoot, inProjectNode=false)
alt encountering ProjectNode
R->>P: inspect assignments
Note right of R #DDEBF7: set inProjectNode = true
R->>R: rewrite expressions in project (inProjectNode=true)
alt sees CLP_GET_JSON_STRING()
R->>R: create placeholder var (JSON_STRING_PLACEHOLDER)
R->>T: add synthetic ClpColumnHandle -> placeholder var mapping
R->>P: replace expression with placeholder var
end
R-->>Q: return modified ProjectNode + updated TableScan outputs
else encountering FilterNode
Note right of R #F7E7E7: inProjectNode = false
R->>R: standard CLP_GET_* rewriting in predicate
R-->>Q: return modified predicate
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
gibber9809
left a comment
There was a problem hiding this comment.
Really just had one comment, but otherwise looks good.
| expression.getSourceLocation(), | ||
| JSON_STRING_PLACEHOLDER, | ||
| call.getType()); | ||
| ClpColumnHandle targetHandle = new ClpColumnHandle(JSON_STRING_PLACEHOLDER, call.getType()); |
There was a problem hiding this comment.
Would it be possible to record in ClpColumnHandle that this is a JSON string like we talked about in the other PR, or do we plan on leaving that for future work?
There was a problem hiding this comment.
Yeah, I linked an issue with this PR. We can probably leave it to the future work. One possible fix is to add a field isJsonStringColumn in ClpColumnHandle.
gibber9809
left a comment
There was a problem hiding this comment.
LGTM. For the PR title, I think we just need to add a period:
feat: Add `clp_get_json_string` UDF.
clp_get_json_string UDFclp_get_json_string UDF.
d02268d
into
y-scope:release-0.293-clp-connector
Description
This PR introduces the
clp_get_json_stringUDF, which is rewritten into a special column named__json_stringduring UDF rewriting. With Velox support, this UDF enables fetching a serialized JSON string representation of a row.Note:
clp_get_json_stringis currently supported only in projection fields.Checklist
breaking change.
Validation performed
Did an end-to-end testing with a sample dataset
Summary by CodeRabbit
New Features
Improvements
Tests