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

Implement current_date scalar function #4022

Merged
merged 3 commits into from
Oct 31, 2022
Merged

Conversation

comphead
Copy link
Contributor

@comphead comphead commented Oct 29, 2022

Which issue does this PR close?

Closes #3981

Rationale for this change

DataFusion users need to be able to use the current date to calculate things like "all data in the last 30 days"

What changes are included in this PR?

Scalar current_date function

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate logical-expr Logical plan and expressions physical-expr Physical Expressions labels Oct 29, 2022
@comphead comphead mentioned this pull request Oct 29, 2022
2 tasks
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks great to me @comphead -- thank you!

I left some minor suggestions, but I think this PR could be merged in without changes as well.

DataType::Date32
);

let sql = "select case when current_date() = cast(now() as date) then 'OK' else 'FAIL' end result";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -254,6 +258,7 @@ impl BuiltinScalarFunction {

// Stable builtin functions
BuiltinScalarFunction::Now => Volatility::Stable,
BuiltinScalarFunction::CurrentDate => Volatility::Stable,
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

datafusion/expr/src/expr_fn.rs Outdated Show resolved Hide resolved
datafusion/physical-expr/src/functions.rs Outdated Show resolved Hide resolved
comphead and others added 2 commits October 30, 2022 11:07
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
@jimexist
Copy link
Member

if this is merged first then i'll need to update:

@alamb
Copy link
Contributor

alamb commented Oct 31, 2022

Since this appears to have some other work building behind it and it has two approvals, merging it in!

@alamb alamb merged commit f91eddf into apache:master Oct 31, 2022
@alamb
Copy link
Contributor

alamb commented Oct 31, 2022

Thanks again @comphead and @jimexist

@ursabot
Copy link

ursabot commented Oct 31, 2022

Benchmark runs are scheduled for baseline = 35f786b and contender = f91eddf. f91eddf 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

jimexist pushed a commit to jimexist/arrow-datafusion that referenced this pull request Oct 31, 2022
* current_date impl

* Update datafusion/expr/src/expr_fn.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* Update datafusion/physical-expr/src/functions.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Dandandan pushed a commit to yuuch/arrow-datafusion that referenced this pull request Nov 5, 2022
* current_date impl

* Update datafusion/expr/src/expr_fn.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* Update datafusion/physical-expr/src/functions.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
MazterQyou pushed a commit to cube-js/arrow-datafusion that referenced this pull request Jun 2, 2023
* current_date impl

* Update datafusion/expr/src/expr_fn.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* Update datafusion/physical-expr/src/functions.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
MazterQyou pushed a commit to cube-js/arrow-datafusion that referenced this pull request Jun 2, 2023
* current_date impl

* Update datafusion/expr/src/expr_fn.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* Update datafusion/physical-expr/src/functions.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement current_date Function
4 participants