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

[SQL] Add the mathematical constant PI #1123

Merged
merged 4 commits into from
Dec 9, 2023
Merged

[SQL] Add the mathematical constant PI #1123

merged 4 commits into from
Dec 9, 2023

Conversation

abhizer
Copy link
Contributor

@abhizer abhizer commented Dec 8, 2023

  • Also updates the sin and cos tests to use PI instead of 3.14

Is this a user-visible change (yes/no): yes

Fixes: #1115

@abhizer abhizer added documentation Improvements or additions to documentation SQL compiler Related to the SQL compiler User-facing For PRs that lead to Feldera-user visible changes labels Dec 8, 2023
@mihaibudiu
Copy link
Collaborator

You should add a Fixes: line to the comments so the corresponding issue is automatically closed.

Copy link
Collaborator

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

I am approving, but a few small changes are needed

@@ -92,4 +92,8 @@ REAL '1.23' -- string style
<td><code>COS(value)</code></td>
<td>The cosine of value as radians. <code>cos</code> only supports argument of type double, so all other types are cast to double. Returns a double.</td>
</tr>
<tr>
<td><code>PI</code></td>
<td>Returns the approximate value of <code>PI</code> as double.</td>
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should add a note that no () is required.

" sin \n" +
"-----\n" +
" 0.0015926529164868282\n" +
" 0\n" + // Postgres disagrees with us here, but currently we round off to 15 decimal places
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this result better.

@@ -86,10 +86,10 @@ public void testSinDouble() {
" 0.8414709848078965\n" +
"(1 row)\n" +
"\n" +
"SELECT sin(CAST(3.14 AS DOUBLE));\n" +
"SELECT sin(CAST(pi AS DOUBLE));\n" +
Copy link
Collaborator

Choose a reason for hiding this comment

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

this one is probably not necessary since pi is already a double.

* Also updates the sin and cos tests to use PI instead of 3.14

Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
* Remove tests that cast PI to double as PI is already double
* Mention that floats are rounded off to 6 and doubles 15 decimal places
in the docs

Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
@abhizer abhizer merged commit a023680 into main Dec 9, 2023
5 checks passed
@abhizer abhizer deleted the pi branch December 9, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation SQL compiler Related to the SQL compiler User-facing For PRs that lead to Feldera-user visible changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SQL] PI() is not supported
2 participants