Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-4970

Wrong results when casting double to bigint or int

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      This query returns the wrong result

      0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(\*) from test_table where (int_id > -3025 and bigint_id <= -256) or (cast(double_id as bigint) >= -255 and double_id <= -5);
      +---------+
      | EXPR$0  |
      +---------+
      | 2769    |
      +---------+
      

      Without the cast, it returns the correct result:

      0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(\*) from test_table where (int_id > -3025 and bigint_id <= -256) or (double_id >= -255 and double_id <= -5);
      +---------+
      | EXPR$0  |
      +---------+
      | 3020    |
      +---------+
      

      By itself, the result is also correct:

      0: jdbc:drill:zk=10.10.100.186:5181/drill/rho> select count(\*) from test_table where (cast(double_id as bigint) >= -255 and double_id <= -5);
      +---------+
      | EXPR$0  |
      +---------+
      | 251     |
      +---------+
      

      Attachments

        1. test_table
          375 kB
          Robert Hou

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            volodymyr Vova Vysotskyi
            rhou Robert Hou
            Chun Chang Chun Chang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment