Apache Drill
  1. Apache Drill
  2. DRILL-988

Trunc func injects a long cast which would cause loss of data

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.4.0
    • Component/s: Functions - Drill
    • Labels:
      None

      Description

      Dill func trunc() currently injects a explicit long cast that would cause data loss.

        Activity

        Hide
        Yash Sharma added a comment -
        Show
        Yash Sharma added a comment - Kindly review: https://reviews.apache.org/r/22607/
        Hide
        Sudheesh Katkam added a comment -

        Truncate should use DOWN rather than ROUND_FLOOR. As Mehant Baid pointed out previously, trunc(-123.5) should result in -123 and not -124.

        new BigDecimal(-123.5).setScale(0, BigDecimal.ROUND_FLOOR) = -124

        new BigDecimal(-123.5).setScale(0, BigDecimal.DOWN) = -123

        Show
        Sudheesh Katkam added a comment - Truncate should use DOWN rather than ROUND_FLOOR. As Mehant Baid pointed out previously, trunc(-123.5) should result in -123 and not -124. new BigDecimal(-123.5).setScale(0, BigDecimal.ROUND_FLOOR) = -124 new BigDecimal(-123.5).setScale(0, BigDecimal.DOWN) = -123
        Hide
        Yash Sharma added a comment -

        Implemented review comment

        Show
        Yash Sharma added a comment - Implemented review comment
        Hide
        Yash Sharma added a comment -

        Added properly formatted patch

        Show
        Yash Sharma added a comment - Added properly formatted patch
        Hide
        Yash Sharma added a comment -

        Will be fixed along with DRILL-706 patch.

        Show
        Yash Sharma added a comment - Will be fixed along with DRILL-706 patch.
        Hide
        Yash Sharma added a comment -

        Implemented review comments.
        Merged patch for DRILL-524,DRILL-706,DRILL-988.
        Testcase: $mvn test -Dtest=TestNewMathFunctions#testTruncDivMod

        Show
        Yash Sharma added a comment - Implemented review comments. Merged patch for DRILL-524 , DRILL-706 , DRILL-988 . Testcase: $mvn test -Dtest=TestNewMathFunctions#testTruncDivMod
        Show
        Yash Sharma added a comment - https://reviews.apache.org/r/22607/
        Hide
        Yash Sharma added a comment -

        Implemented review comments.
        Rebased on current master.

        Show
        Yash Sharma added a comment - Implemented review comments. Rebased on current master.
        Hide
        Mehant Baid added a comment -

        Yash could you please attach the latest patch to the JIRA?

        Show
        Mehant Baid added a comment - Yash could you please attach the latest patch to the JIRA?
        Hide
        Yash Sharma added a comment -

        The 9th july patch is the one that is attached to the review board.

        Show
        Yash Sharma added a comment - The 9th july patch is the one that is attached to the review board.
        Hide
        Jacques Nadeau added a comment -

        fixed by e5c2da0 or earlier

        Show
        Jacques Nadeau added a comment - fixed by e5c2da0 or earlier

          People

          • Assignee:
            DrillCommitter
            Reporter:
            Yash Sharma
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development