Skip to content

Conversation

@Dandandan
Copy link
Contributor

Which issue does this PR close?

Closes #308

Rationale for this change

Simplifies code, probably is faster too. Also involves one cast less which causes more rounding errors.

What changes are included in this PR?

Use arity::unary function to simplify math expression code

Are there any user-facing changes?

No

let sql = "SELECT avg(sqrt(c11)) FROM aggregate_test_100";
let actual = execute(&mut ctx, sql).await;
let expected = vec![vec!["0.6584408485889435"]];
let expected = vec![vec!["0.6584407806396484"]];
Copy link
Contributor Author

@Dandandan Dandandan May 10, 2021

Choose a reason for hiding this comment

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

Small diff, since we avoid as f64 now.

Some(array) => compute_op!(array, $FUNC, $TYPE),
Some(array) => {
let res: $TYPE =
arrow::compute::kernels::arity::unary(array, |x| x.$FUNC());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This avoids creating intermediate Vec and uses the (efficient) unary kernel

Copy link
Member

@jorgecarleitao jorgecarleitao 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. 👍

@Dandandan Dandandan merged commit 11634f3 into apache:master May 10, 2021
@alamb
Copy link
Contributor

alamb commented May 10, 2021

🎉

@houqp houqp added datafusion performance Make DataFusion faster labels Jul 29, 2021
unkloud pushed a commit to unkloud/datafusion that referenced this pull request Mar 23, 2025
* HashMergeJoin metrics

* HashMergeJoin metrics test

* Fix test

* Fix format

* Fix descriptions

* Fix imports

* Update spark/src/test/scala/org/apache/comet/exec/CometExecSuite.scala

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>

* delete conf

* Fix

---------

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>
H0TB0X420 pushed a commit to H0TB0X420/datafusion that referenced this pull request Oct 7, 2025
* Fix broken use of environment variables in GitHub actions

* Fix broken workflow file and add actionlint pre-commit check to prevent future errors

* Install protoc

* Add rustup-components

* fix maturin-action bugs

* add explanation

* add protoc to sdist and manylinux

* Update .github/workflows/build.yml

Co-authored-by: Phillip Cloud <417981+cpcloud@users.noreply.github.com>

* install protobuf compiler

* add protoc

* fix invalid build yaml

* try set protoc path

* try suggestion from ChatGPT

* experiment

* revert change

---------

Co-authored-by: Phillip Cloud <417981+cpcloud@users.noreply.github.com>
Co-authored-by: Ian Alexander Joiner <14581281+iajoiner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Make DataFusion faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify math expressions

4 participants