Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: incomplete error message for the wrong date comparison #30016

Closed
elasticmachine opened this issue Apr 24, 2018 · 1 comment · Fixed by #30138
Closed

SQL: incomplete error message for the wrong date comparison #30016

elasticmachine opened this issue Apr 24, 2018 · 1 comment · Fixed by #30138

Comments

@elasticmachine
Copy link
Collaborator

Original comment by @astefan:

For a test case with dynamic mapping created following (which creates a date type field for release_date):

PUT /library/book/_bulk?refresh
{"index":{"_id": "1"}}
{"name": "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561,"price":33.456}

a (wrong) sql query

POST /_xpack/sql
{
    "query": "SELECT name.keyword FROM library WHERE release_date >= 2011-06-02"
}

gives an error message (expected) but one that is incomplete:

{
  "error": {
    "root_cause": [
      {
        "type": "sql_illegal_argument_exception",
        "reason": "Line %d:%d - Comparisons against variables are not (currently) supported; offender %s in %s"
      }
    ],
    "type": "sql_illegal_argument_exception",
    "reason": "Line %d:%d - Comparisons against variables are not (currently) supported; offender %s in %s"
  },
  "status": 500
}
@costin
Copy link
Member

costin commented Apr 25, 2018

The error message is indeed incorrect however I'm unable to reproduce that the query above throws an exception (it simply translates to a range query).
One thing to note (and this needs to be sorted out in the docs) is that the expression above 2011-06-02 is not a literal and thus evaluates to 2001 minus 06 minus 02 so 1993.
One can use ' to specify it as a literal or a CAST - this is likely to be improved in a future release by extending the date-time support.

@costin costin added the v7.0.0 label Apr 25, 2018
costin added a commit to costin/elasticsearch that referenced this issue Apr 25, 2018
Error messages had placeholders that were not replaced; this PR fixes
that

FIX elastic#30016
costin added a commit that referenced this issue Apr 27, 2018
* SQL: Correct error message

Error messages had placeholders that were not replaced; this PR fixes
that

Fix #30016
costin added a commit that referenced this issue Apr 27, 2018
Error messages had placeholders that were not replaced; this PR fixes
that

Fix #30016
costin added a commit that referenced this issue Apr 27, 2018
Error messages had placeholders that were not replaced; this PR fixes
that

Fix #30016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants