Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-10753

[Rust] [DataFusion] Negative numbers in SQL WHERE clause not parsed correctly

    XMLWordPrintableJSON

Details

    Description

      Negative numbers in SQL WHERE clauses are not parsed correctly:

       

      ```

      > create external table blogs stored as PARQUET location '../../testing/data/parquet/generated_simple_numerics/blogs.par0 rows in set. Query took 0 seconds.
      > select reply, blog_id from blogs where blog_id >= -1000;
      InternalError("SQL binary operator cannot be interpreted as a unary operator")

      ```

      The above can be seen with different data files, and with both integer and floating point negative numbers.    The exception comes from planner.rs sql_to_rex() function, in the UnaryOp case, so it is data independent.   jorgecarleitao  seems you have made commits here, WDYT?

      I'm not sure if the problem is SQLParser itself but the fix seems quite easy, basically to parse this:

      UnaryOp { op: Minus, expr: Value(Number("1")) }

      It can be seen in latest master also.

      I'm up for contributing a fix if this is confirmed as a bug.

      Attachments

        Issue Links

          Activity

            People

              velvia Evan Chan
              velvia Evan Chan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h