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

Move from_unixtime, now, current_date, current_time functions to datafusion-functions #9537

Merged
merged 27 commits into from
Mar 13, 2024

Conversation

Omega359
Copy link
Contributor

Which issue does this PR close?

Closes #9466

Rationale for this change

Functions are migrated to the new crate and use the new patterns as described in #9286 & #9216

What changes are included in this PR?

Code, tests moved to new location, references updated.

Are these changes tested?

Yes

Are there any user-facing changes?

No

Omega359 and others added 24 commits March 2, 2024 20:47
# Conflicts:
#	datafusion/proto/src/logical_plan/from_proto.rs
…lain text to reflect the change. The physical plan is unchanged.
# Conflicts:
#	datafusion/proto/src/logical_plan/from_proto.rs
# Conflicts:
#	datafusion/physical-expr/src/equivalence/projection.rs
# Conflicts:
#	datafusion/physical-expr/src/equivalence/projection.rs
# Conflicts:
#	datafusion/physical-expr/src/equivalence/projection.rs
# Conflicts:
#	datafusion/core/tests/optimizer_integration.rs
#	datafusion/physical-expr/src/datetime_expressions.rs
#	datafusion/proto/src/logical_plan/from_proto.rs
# Conflicts:
#	datafusion/expr/src/built_in_function.rs
#	datafusion/expr/src/expr_fn.rs
#	datafusion/functions/src/datetime/date_bin.rs
#	datafusion/functions/src/datetime/mod.rs
#	datafusion/physical-expr/src/datetime_expressions.rs
#	datafusion/physical-expr/src/functions.rs
#	datafusion/proto/src/logical_plan/from_proto.rs
@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Physical Expressions optimizer Optimizer rules core Core DataFusion crate labels Mar 10, 2024
@@ -342,7 +343,12 @@ fn test_sql(sql: &str) -> Result<LogicalPlan> {
let statement = &ast[0];

// create a logical query plan
let context_provider = MyContextProvider::default();
let now_udf = datetime::functions()
Copy link
Contributor

Choose a reason for hiding this comment

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

How much of the optimizer integration test do you think needs Udfs? I am wondering maybe we could just port the tests case for now() into core/tests/sql_integration` or something and eave the rest of the optimizer_integration test in the optimizer crate?

The reason it might be good to leave the optimzer tests in the optimizer crate are

  1. Easier to run cargo test -p datafusion_optimizer and run all the relevant tests
  2. Ensure that we could still use datafusion_optimizer without the function definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll take a look. 6/20 tests use functions in the test (concat, sum, concat_ws, now(), avg). I can move just those over for sure. I wish this test dependency issue wasn't such an problem in Rust - most of the problems I've seen migrating the functions have been test related.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about this more - the issue is not test related because we can use dev dependencies. The issue is publishing to crates.io because cargo publishes with dev-dependencies and has been for many many years according to the bug report. Would it be possible to just fix that by the use of --no-dev-deps or something similar during publishing?

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think moving the tests to the core (what this PR does) is probably the best solution for now, as it correctly reflects the dependencies (the optimizer tests are testing behavior of functions that are not available to optimizer)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved all but the tests that required now() back to the datafusion/optimizer/tests folder.

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.

Thank you @Omega359 -- this is looking very nice 🙏
The only question I have is about moving datafusion/core/tests/optimizer_integration.rs

Let me know your thoughts. Thanks again

_args: Vec<Expr>,
info: &dyn SimplifyInfo,
) -> Result<ExprSimplifyResult> {
let now_ts = info.execution_props().query_execution_start_time;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

# Conflicts:
#	datafusion/expr/src/built_in_function.rs
#	datafusion/expr/src/expr_fn.rs
#	datafusion/proto/proto/datafusion.proto
#	datafusion/proto/src/generated/pbjson.rs
#	datafusion/proto/src/generated/prost.rs
#	datafusion/proto/src/logical_plan/from_proto.rs
#	datafusion/proto/src/logical_plan/to_proto.rs
…s to the core/tests folder, leave the rest in place.
@@ -342,7 +343,12 @@ fn test_sql(sql: &str) -> Result<LogicalPlan> {
let statement = &ast[0];

// create a logical query plan
let context_provider = MyContextProvider::default();
let now_udf = datetime::functions()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think moving the tests to the core (what this PR does) is probably the best solution for now, as it correctly reflects the dependencies (the optimizer tests are testing behavior of functions that are not available to optimizer)

@alamb
Copy link
Contributor

alamb commented Mar 13, 2024

🚀 - thank you @Omega359

@alamb alamb merged commit 9d47dca into apache:main Mar 13, 2024
24 checks passed
@Omega359 Omega359 deleted the feature/9466 branch March 13, 2024 16:10
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 optimizer Optimizer rules physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move from_unixtime, now, current_date, current_time functions to datafusion-functions
3 participants