[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2023-02-14 Thread via GitHub


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1430183682

   @cloud-fan, I've updated the code review suggestions, can you please review 
this PR ?


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2023-02-03 Thread via GitHub


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1416668924

   @dtenedor , thanks for the review comments, I applied the changes 


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2023-02-01 Thread via GitHub


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1412537998

   @cloud-fan , @gengliangwang Can you please review this PR?


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2023-01-27 Thread via GitHub


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1406762292

   @srielau , I fixed the review comments. Can you please review this PR again?


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2023-01-19 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1397810091

   > What is the result type? Does it match the input?
   
   Yes, result type will match the input type


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2023-01-18 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1387448824

   @srielau , @dtenedor , @cloud-fan Code review comments are applied
   Can you please review this PR..


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2022-12-20 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1359684896

   @cloud-fan , I fixed the review comments, can you please take a look at this 
PR?


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2022-12-04 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1336776081

   @cloud-fan , Can you please review it?


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2022-11-15 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1315715844

   @cloud-fan , yes we could share common code among 3 functions (trunc, floor, 
ceil).
   Updated the PR


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2022-11-09 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1309200366

   @cloud-fan , Though ceil/floor takes a second parameter for num of digits to 
retain, the behaviour is different in trunc and ceil/floor functions
   
   Eg:  FLOOR vs TRUNC comparison
   
   | FLOOR  | Result  | TRUNC  | Result  |   |
   |---|---|---|---|---|
   | SELECT FLOOR(-2.5, 0)  | -3  |SELECT TRUNC(-2.5, 0)   | -2  |   |
   | SELECT FLOOR(-3.5, 0)  | -0.4  | SELECT TRUNC(-3.5, 0)  | -3  |   |
   | SELECT FLOOR(-35, -1)  | -40  | SELECT TRUNC(-35, -1)  | -30  |   |
   | SELECT FLOOR(-9.9, 0)  | -10  | SELECT TRUNC(-9.9, 0)  |-9   |   |
   | SELECT FLOOR(CAST(-99 AS DECIMAL(2, 0)), -1)  | -100  | SELECT 
TRUNC(CAST(-99 AS DECIMAL(2, 0)), -1)  | -90   |   |
   
   
   Eg:  CEIL vs TRUNC comparison
   
   | CEIL  | Result  | TRUNC  | Result  |   |
   |---|---|---|---|---|
   |SELECT CEIL(2.5, 0) | 3 | SELECT TRUNC(2.5, 0) | 2 |  |
   |SELECT CEIL(3.5, 0) | 4 | SELECT TRUNC(3.5, 0) | 3 |  |
   |SELECT CEIL(0.35, 1) |0.4  | SELECT TRUNC(0.35, 1) | 0.3  |  |
   |SELECT CEIL(35, -1) | 40 | SELECT TRUNC(35, -1 | 30 |  |
   |SELECT CEIL(5, 0) | 5 | SELECT TRUNC(5, 0)| 5 |  |
   |SELECT CEIL(9.9, 0) | 10 | SELECT TRUNC(9.9, 0) | 9 |  |
   |SELECT CEIL(CAST(99 AS DECIMAL(2, 0)), -1) | 100  | SELECT TRUNC(CAST(99 AS 
DECIMAL(2, 0)), -1) | 90 |  |
   


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2022-11-08 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1307418547

   @cloud-fan , thanks for the review/question.
   
   `floor` returns a numeric value containing the largest integers not greater 
than the corresponding elements of x. 
   `trunc`  returns a numeric value containing the integers formed by 
truncating the values in x toward 0
   
   Eg: 
   `trunc(x, n)` → double
   Returns x truncated to n decimal places. n can be negative to truncate n 
digits left of the decimal point. Unlike ceil or floor, this function will not 
round up/down the number, rather it just truncates by replacing with '0'
   
   Example: 
`trunc(REAL '12.333', -1)` -> result is `10`
`trunc(REAL '123.333', -2)` -> result is `100`
`trunc(REAL '12.333', 0)` -> result is `12`
`trunc(REAL '12.333', 1)` -> result is `12.3`
   
   Reference  from other Database :
   - [AWS redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_TRUNC.html)
   - [PostgreSQL](https://www.postgresql.org/docs/15/functions-math.html)
   - 
[Presto](https://prestodb.io/docs/current/functions/math.html?highlight=trunc#id3)
   - 
[Mysql](https://database.guide/mysql-truncate-function-truncate-a-number-to-a-specified-number-of-decimal-places/)
   - 
[Oracle](https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions200.htm#:~:text=The%20TRUNC%20(number)%20function%20returns,left%20of%20the%20decimal%20point.)
   
   `floor(x)`
   Returns x rounded down to the nearest integer.


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2022-11-07 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1306020518

   cc @wangyum , @cloud-fan Can you please review this PR?


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] vinodkc commented on pull request #38419: [SPARK-40945][SQL] Support built-in function to truncate numbers

2022-10-27 Thread GitBox


vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1294221419

   @HyukjinKwon , @dongjoon-hyun , Can you please review this PR?


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org