feat: add function rewrite rule for json_get with cast#7631
feat: add function rewrite rule for json_get with cast#7631sunng87 merged 9 commits intoGreptimeTeam:mainfrom
Conversation
Summary of ChangesHello @sunng87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the SQL query engine's capabilities by introducing a robust function rewrite framework. This framework is immediately leveraged to provide more intuitive and powerful type casting for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a function rewrite rule to support CAST operations on the json_get function, allowing for a more natural SQL syntax like json_get(...)::type. The implementation involves creating a FunctionRewrite rule, registering it with the query engine, and modifying the json_get function to handle the rewritten expression.
My review has found a critical issue where the new functionality appears to be broken in the provided tests. Additionally, I've identified a potential robustness issue in the new rewrite rule. Please see my detailed comments.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ef77cd07f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Convert to draft for now. I'm going to remove the arrow_cast trasformation in Update: not removable. We still need arrow_cast for timestamps |
|
@sunng87 I think this feature could be implemented as a Similar to how type aliasing is handled: It doesn't need to be implemented as an analyzer rule. |
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
|
@killme2008 Yes it's possible. This change is to use datafusion function rewriter API: https://docs.rs/datafusion/latest/datafusion/logical_expr/expr_rewriter/trait.FunctionRewrite.html and make this API work on our implementation. |
|
@sunng87 Conflicts must be resolved. |
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
This patch provides support for sql like
It also changes the third argument of
json_getto accept value type instead of type name.Note that we have a sql transform rewrite
type_aliasthat rewrites::int8toarrow_castfunction calls. So we will deal with botharrow_castfunction call and cast expression here.PR Checklist
Please convert it to a draft if some of the following conditions are not met.