You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Syleechan (via GitHub)" <gi...@apache.org> on 2023/07/26 02:33:54 UTC
[GitHub] [arrow-datafusion] Syleechan commented on a diff in pull request #7042: Minor: add test + docs for 2 argument trunc with columns
Syleechan commented on code in PR #7042:
URL: https://github.com/apache/arrow-datafusion/pull/7042#discussion_r1274303313
##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -507,14 +507,17 @@ tanh(numeric_expression)
Truncates a number toward zero (at the decimal point).
```
-trunc(numeric_expression)
+trunc(numeric_expression[, decimal_places])
```
#### Arguments
- **numeric_expression**: Numeric expression to operate on.
Can be a constant, column, or function, and any combination of arithmetic operators.
+- **decimal_places**: Optional. The number of decimal places to truncate to.
+ Defaults to 0.
Review Comment:
>
can not be negative, modify the trunc function just meet the self-defined precision of decimal to '.'
##########
datafusion/core/tests/sqllogictests/test_files/scalar.slt:
##########
@@ -918,6 +918,15 @@ select trunc(4.267, 3), trunc(1.1234, 2), trunc(-1.1231, 6), trunc(1.2837284, 2)
----
4.267 1.12 -1.1231 1.28 1
+# trunc with columns and precision
+query RRR rowsort
+select trunc(a, 3) as a3, trunc(a, 1) as a1, trunc(arrow_cast(a, 'Float64'), 3) as a3_f64 from small_floats;
+----
+-0.7 -0.7 -0.7
+-1 -1 -1
+0.2 0.2 0.2
+0.5 0.5 0.5
Review Comment:
maybe add some long decimal point float number
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org