-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constant fold / optimize to_timestamp
function during planning
#387
Conversation
Codecov Report
@@ Coverage Diff @@
## master #387 +/- ##
==========================================
- Coverage 74.94% 74.84% -0.10%
==========================================
Files 146 146
Lines 24314 24553 +239
==========================================
+ Hits 18221 18377 +156
- Misses 6093 6176 +83
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -217,6 +218,29 @@ impl<'a> ExprRewriter for ConstantRewriter<'a> { | |||
.query_execution_start_time | |||
.timestamp_nanos(), | |||
))), | |||
Expr::ScalarFunction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matching on the literal argument is good as the rewrite
pass happens after all children are visited 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @msathis for the work. It will help us to push predicate with this type of constant down the plan in InfluxDB_IOx. I just have a few minor comments
args, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happen if the args.is_empty()
? Do we use a default value or return syntax error we simply return false
for this expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of all error cases including empty, we don't optimise. So the default non-optimised flow continues.
let table_scan = test_table_scan().unwrap(); | ||
let proj = vec![Expr::ScalarFunction { | ||
args: vec![Expr::Literal(ScalarValue::Utf8(Some( | ||
"I'M NOT A TIMESTAMP".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_timestamp
function during planning
Oh no -- we have some clippy errors https://github.com/apache/arrow-datafusion/pull/387/checks?check_run_id=2658215529
|
For some strange reason |
I pushed the clippy change -- hopefully that will get this PR to green |
It may be related to what version of rust is used. I also have some troubles with clippy sometimes not finding errors. I run the following locally (I am somewhat embarrassed but it does work for me 🤷 )
|
Thanks. That's nice. I'll copy & use it 👍 |
Touching the files (or cleaning the build) should not be needed anymore since 1.52 https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html
|
Thanks again @msathis ! |
…che#387) * optimize to_timestamp * cargo fmt * fix clippy * Added testcase & removed optimization for invalid timestamps * Added negative testcase * Fix clippy * fix clippy Co-authored-by: Sathis Kumar <sathis.kumar@udemy.com> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Which issue does this PR close?
Fixes #383
Rationale for this change
Optimize to_timestamp function
What changes are included in this PR?
Optimize to_timestamp function
Are there any user-facing changes?
N/A