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

feat(expr): Various trigonometric functions #8838

Merged
merged 23 commits into from
Mar 30, 2023
Merged

feat(expr): Various trigonometric functions #8838

merged 23 commits into from
Mar 30, 2023

Conversation

CAJan93
Copy link
Contributor

@CAJan93 CAJan93 commented Mar 28, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Implement the following math functions

  • sin / cos / tan / cot / asin / acos / atan / atan2

Related PR: #8806

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • I have demonstrated that backward compatibility is not broken by breaking changes and created issues to track deprecated features to be removed in the future. (Please refer to the issue)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Checklist For Reviewers

  • I have requested macro/micro-benchmarks as this PR can affect performance substantially, and the results are shown.

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

Comment on lines 503 to 504
#[must_use]
pub fn sin(&self) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI In PostgreSQL, trigonometric functions are only defined for double precision. Inputs of other types are implicitly casted to double precision, and the output is always double precision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing that out :)

@CAJan93 CAJan93 marked this pull request as ready for review March 29, 2023 10:52
@CAJan93 CAJan93 requested a review from xiangjinwu March 29, 2023 10:52
@CAJan93 CAJan93 enabled auto-merge March 29, 2023 10:52
@@ -18,191 +18,191 @@ publish = false

### BEGIN HAKARI SECTION
[dependencies]
ahash = { version = "0.8" }
anyhow = { version = "1", features = ["backtrace"] }
ahash = { version = "0.8", features = ["getrandom", "runtime-rng", "std"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes were added after risedev c

src/common/Cargo.toml Outdated Show resolved Hide resolved
query R
SELECT cot(1)
----
0.642092615934331
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is not run by the CI. It needs to be named as trigonometric.slt.part.

And you can run it locally:

sqllogictest -p 4566 -d dev './e2e_test/batch/functions/trigonometric.slt.part'

@CAJan93
Copy link
Contributor Author

CAJan93 commented Mar 30, 2023

Thank you for your feedback. I changed the tests slightly (see 7d53b64). These are mostly rounding errors. I assume those differences are ok?

@CAJan93 CAJan93 changed the title feat(frontend): Various math functions feat(frontend): Various trigonometric functions Mar 30, 2023
@xiangjinwu
Copy link
Contributor

These are mostly rounding errors. I assume those differences are ok?

I think so. PostgreSQL also includes similar disclaimer:

The functions working with double precision data are mostly implemented on top of the host system's C library; accuracy and behavior in boundary cases can therefore vary depending on the host system.

@xiangjinwu xiangjinwu changed the title feat(frontend): Various trigonometric functions feat(expr): Various trigonometric functions Mar 30, 2023
@CAJan93 CAJan93 added this pull request to the merge queue Mar 30, 2023
@codecov
Copy link

codecov bot commented Mar 30, 2023

Codecov Report

Merging #8838 (9f0f1db) into main (bccc76d) will increase coverage by 0.00%.
The diff coverage is 95.00%.

@@           Coverage Diff           @@
##             main    #8838   +/-   ##
=======================================
  Coverage   70.79%   70.80%           
=======================================
  Files        1180     1181    +1     
  Lines      195692   195772   +80     
=======================================
+ Hits       138539   138615   +76     
- Misses      57153    57157    +4     
Flag Coverage Δ
rust 70.80% <95.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/expr/src/vector_op/trigonometric.rs 94.36% <94.36%> (ø)
src/frontend/src/binder/expr/function.rs 89.31% <100.00%> (+0.16%) ⬆️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Merged via the queue into main with commit bf616d8 Mar 30, 2023
@CAJan93 CAJan93 deleted the math_funcs branch March 30, 2023 15:46
@neverchanje neverchanje added the user-facing-changes Contains changes that are visible to users label May 9, 2023
@CharlieSYH CharlieSYH added the 📖✓ Covered or will be covered in the user docs. label May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users 📖✓ Covered or will be covered in the user docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants