Skip to content
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

Add support for DataType::Timestamp casts in unwrap_cast_in_comparison optimizer pass #4148

Merged
merged 3 commits into from
Nov 12, 2022

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Nov 8, 2022

Draft as it builds on tests in #4147

Which issue does this PR close?

Closes #3938

Rationale for this change

I want predicates that compare timestamp columns and now() to be fully optimized / pruned. See #3938 and https://github.com/influxdata/influxdb_iox/issues/5875 for more details

What changes are included in this PR?

  1. Add support for DataType::Timestamp in unwrap_cast_in_comparison optimizer pass
  2. Tests

Are these changes tested?

Yes (I wrote a whole new set of tests just for this :) )-- #4147

Are there any user-facing changes?

Hopefully faster queries

@github-actions github-actions bot added the optimizer Optimizer rules label Nov 8, 2022
] {
let utc = Some("+0:00".to_string());
// No timezone, utc timezone
let (lit_tz_none, lit_tz_utc) = match time_unit {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note on the timezone handling is that expect_cast added in #4147 and used in this PR explicitly verifies that calling the arrow cast kernel produces the same result as the code in this PR.

@@ -236,7 +236,8 @@ fn timestamp_nano_ts_none_predicates() -> Result<()> {
// constant and compared to the column without a cast so it can be
// pushed down / pruned
let expected =
"Projection: test.col_int32\n Filter: CAST(test.col_ts_nano_none AS Timestamp(Nanosecond, Some(\"+00:00\"))) < TimestampNanosecond(1666612093000000000, Some(\"+00:00\"))\
"Projection: test.col_int32\
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is finally fixed! Note there is no cast on the test.col_ts_nano_none column

@liukun4515
Copy link
Contributor

If your pr is ready, please ping me.

@alamb alamb marked this pull request as ready for review November 9, 2022 18:34
@alamb
Copy link
Contributor Author

alamb commented Nov 9, 2022

This PR is now ready for review @liukun4515

As an aside, I found working with this code to be quite straightforward -- thank you to @liukun4515 for the nice structure and tests

@alamb
Copy link
Contributor Author

alamb commented Nov 11, 2022

@liukun4515 if you have a moment to review this PR I would appreciate it (as I have another PR with support for unsigned type support backed up behind it). 🙏

Copy link
Contributor

@liukun4515 liukun4515 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@liukun4515
Copy link
Contributor

This PR is now ready for review @liukun4515

As an aside, I found working with this code to be quite straightforward -- thank you to @liukun4515 for the nice structure and tests

very happy to hear that

@alamb alamb merged commit bcd8af8 into apache:master Nov 12, 2022
@ursabot
Copy link

ursabot commented Nov 12, 2022

Benchmark runs are scheduled for baseline = 129654c and contender = bcd8af8. bcd8af8 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@alamb alamb deleted the alamb/unwrap_timestamp_casts branch August 8, 2023 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimizer Optimizer rules
Projects
None yet
3 participants