Skip to content

[BUG] Advanced functions causes SyntaxAnalysisException #172

Closed

Description

@jeje22

Describe the bug
I am using AWS OpenDistro 7.10 with SQL queries.
Using advanced functions in select clause gives SyntaxAnalysisException whereas simple functions works.

Example
Working example:

  • SELECT DATE_FORMAT(data.timestamp, 'yyyy-MM-dd HH:mm:00.000') data__timestamp1m FROM data* AS data WHERE (data.timestamp between '2021-07-19T08:40:00Z' AND '2021-07-20T13:00:00Z') GROUP BY DATE_FORMAT(data.timestamp, 'yyyy-MM-dd HH:mm:00.000') ORDER BY DATE_FORMAT(data.timestamp, 'yyyy-MM-dd HH:mm:00.000') DESC LIMIT 1000

Failing example:

  • SELECT CASE WHEN MINUTE(data.timestamp) % 2 = 1 THEN DATE_FORMAT(ADDDATE(data.timestamp, INTERVAL 1 minute), 'yyyy-MM-dd HH:mm:00.000') ELSE DATE_FORMAT(data.timestamp, 'yyyy-MM-dd HH:mm:00.000') END data__timestamp2m FROM data* AS data WHERE (telemetry_yuri.timestamp between '2021-07-19T08:40:00Z' AND '2021-07-20T13:00:00Z') GROUP BY data__timestamp2m ORDER BY data__timestamp2m DESC LIMIT 1000

To Reproduce
Steps to reproduce the behavior:

  1. check that a simple query give results without errors
  2. check that an advances query give a SyntaxAnalysisException

Expected behavior
Advanced query to work or having a workaround

Host/Environment (please complete the following information):

  • OS: aws linux 2
  • Version 7.10.2

Additional context
Our use case is we want to group data into buckets of some period of time, on 1 min for example it works easily but on other we need more complex logic. It worked when I replace the between in the where clause to a >= and <= but this creates painless scripts which slows down the query.

Activity

  1. dblock commented on Aug 3, 2021

    @dblock
    Member

    Moved to sql repo.

  2. dai-chen commented on Sep 29, 2022

    @dai-chen
    Collaborator

    Checked again but BETWEEN seems still missing in engine v2.

  3. added
    bug
    legacy
    on Sep 29, 2022
  4. added
    v2.5.0
    on Dec 12, 2022
  5. self-assigned this
    on Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

SQLbuglegacyv2.5.0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions