Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3717

Dividing by nullable numeric throws "ArithmeticException: Division by zero"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.21.0
    • 1.24.0
    • None
    • None

    Description

      Hi, community. We use Calcite-1.21 to connect and compute data resident in PostgreSQL and MySQL. It works pretty well. But we encountered a problem yesterday.

      Firstly, we combine data from different datasources.

      Assume the combined table is T(...., c1, c2, c3), in which c1, c2, c3 are integer columns. Then according to our business logic, we need to perform further data processing in Calcite.

      select case when c1=0 then ..
                  when c2=0 then 1.0/c1 + ...
                  when c3=0 then 1.0/c1 + 1.0/c2 + ...
             else -99.99 end 
      from T

      However, the query throws "java.lang.ArithmeticException: Division by zero".

      Anything goes wrong?

      Attachments

        Issue Links

          Activity

            People

              donnyzone Feng Zhu
              HM Hank Miller
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: