Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-7805

NumericLiteral toSql() should render zero as 0, not 0-E38, 0.000, etc.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Impala 3.0
    • None
    • Frontend
    • None
    • ghx-label-2

    Description

      Testing of other issues revealed a somewhat bizarre aspect of how the planner expression nodes render 0. NumericLiteral.toSql() uses the Java BigDecimal class to convert a numeric value to a string for use in explained plans.

      The default Java behavior is to consider scale when rendering numbers, including 0. Thus, depending on precision and scale, you may get:

      0
      0.0
      0.00
      0.000
      ...
      0E-38
      

      Mathematically, zero is zero. Unlike Java, SQL attaches no significance to the decimal point. (In Java, 0 is an integer, 0.0 is a float.) Nor does SQL attach significance to the number of zeros past the decimal point. And, of course, we're only talking about the output of EXPLAIN, which is never parsed anyway (except in tests.)

      To make testing easier, change the behavior to always emit "0" when the value is zero, regardless of precision or scale.

      Attachments

        Issue Links

          Activity

            People

              Paul.Rogers Paul Rogers
              Paul.Rogers Paul Rogers
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: