Skip to content

[BUG] Multiplication in queries are treated as an alias #265

Closed as not planned

Description

Describe the bug
Multiplication in queries are treated as an alias if there is no space between * and the value.

Or for query issues:

  1. 'SELECT 1*1'
  2. See result of 1 with alias *1

Expected behavior
The result should be 1 similar to result of the query 'SELECT 1/1'

Screenshots
image
image
image

Additional context
'SELECT 1 * 1' works however when TDVT testing, generated queries do not include a space between * and the second value.

Activity

  1. ghost added on Nov 4, 2021
  2. ghost added
    bug
    on Nov 4, 2021
  3. added and removed on Nov 13, 2021
  4. chloe-zh commented on Nov 14, 2021

    @chloe-zh
    Contributor

    Thanks for reporting this issue, this seems due to unhandled corner cases for the parsers. We will give it a fix once we have resources.

  5. added
    tdvt
    on Nov 24, 2021
  6. changed the title [-]Multiplication in queries are treated as an alias[BUG][/-] [+][BUG] Multiplication in queries are treated as an alias[/+] on Sep 27, 2022
  7. added
    legacy
    on Sep 27, 2022
  8. acarbonetto commented on Oct 18, 2022

    @acarbonetto
    Collaborator

    @dai-chen @penghuo
    @GabeFernandez310 has pushed changes to the parser to accommodate index names that included non-SQL characters: Bit-Quill#128

    The current strategy uses state to save whether we're in a FROM clause or not (all other clauses use the default state... more on this below). The state is exited when the index name token is parsed. So, only in this state can we accept non-sql characters in the identifier. A cleaner solution would be to save states for each clause, but that's a major change.

    The parser only fails in unique cases where the test has sub-queries. We need to find out how to accommodate sub-queries, and it seems like the best strategy would be to save state in modes as a stack (push state when entering the sub-query, exit state when we exit the sub-query).

    See test output for review: https://github.com/Bit-Quill/opensearch-project-sql/actions/runs/3268789572

  9. self-assigned this
    on Dec 14, 2022
  10. added
    v2.5.0
    on Dec 14, 2022
  11. removed their assignment
    on Dec 14, 2022
  12. removed
    v2.5.0
    on Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SQLbuglegacytdvt

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions