Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Wrong grammar for negative number #488

@dai-chen

Description

@dai-chen

The negative integer and floating-point number is matched wrongly in current ANTLR grammar. This bug seems introduced since the very beginning when new ANTLR parser was added. Here is an example:

PUT float-test/_doc/1
{
  "balance": 1.23
}

PUT float-test/_doc/2
{
  "balance": 2.21
}

PUT float-test/_doc/3
{
  "balance": -746.0000000000075
}

POST _opendistro/_sql?pretty
{
  "query": """
    SELECT
      balance FROM null-sum-test WHERE balance > -746
  """
}
{
  "error": {
    "reason": "Invalid SQL query",
    "details": "*Field [-746] cannot be found or used here.*",
    "type": "SemanticAnalysisException"
  },
  "status": 400
}

POST _opendistro/_sql?pretty
{
  "query": """
    SELECT
      balance FROM null-sum-test WHERE balance > -1.0
  """
}
{
  "error": {
    "reason": "Invalid SQL query",
    "details": "Failed to parse query due to *offending symbol [.0]* at: 
    '\n    SELECT\n      balance FROM null-sum-test WHERE balance > -1.0' <--- HERE... 
    More details: extraneous input '.0' expecting <EOF>",
    "type": "SyntaxAnalysisException"
  },
  "status": 400
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions