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

Unable to escape characters for string literals[BUG] #297

Closed
ghost opened this issue Nov 22, 2021 · 5 comments
Closed

Unable to escape characters for string literals[BUG] #297

ghost opened this issue Nov 22, 2021 · 5 comments
Labels
bug Something isn't working tdvt Tableau test framework

Comments

@ghost
Copy link

ghost commented Nov 22, 2021

Describe the bug
Unable to escape characters for string literals

Or for query issues:

  1. Run the query SELECT 'i\'m'
  2. See unexpected result i\'m

Expected behavior
The result should be i'm

Screenshots
image

@ghost ghost added Beta bug Something isn't working untriaged labels Nov 22, 2021
@ghost
Copy link
Author

ghost commented Nov 22, 2021

This issue affects TDVT tests:

  • exprtests/standard\setup.logical.txt

@anirudha anirudha added the tdvt Tableau test framework label Nov 24, 2021
@Yury-Fridlyand
Copy link
Collaborator

Adding more info to this bug:

  • PPL and SQL both affected
  • character escaping rules are not applied to all string literals

Some examples:

SELECT 'Pat O''Hanrahan & <Matthew Eldridge]'''

returns
Pat O''Hanrahan & <Matthew Eldridge]'' instead of Pat O'Hanrahan & <Matthew Eldridge]'

SELECT * FROM staples WHERE `Customer Name` = "Mary O'Rourke";

returns valid result, but

SELECT * FROM staples WHERE `Customer Name` = 'Mary O\'Rourke';

yields empty result set.
In case of PPL

source=staples | WHERE `Customer Name` = "Mary O'Rourke";

returns valid data, but

source=staples | WHERE `Customer Name` = 'Mary O\'Rourke';

doesn't.

staples table is a sample data from TDVT suite.

@MaxKsyunz
Copy link
Collaborator

Adding the following test to sql/src/test/java/org/opensearch/sql/sql/parser/AstExpressionBuilderTest.java will also reproduce the problem.

 @Test
  public void canBuildEscapedStringLiteral() {
    assertEquals(
            stringLiteral("O'Rourke"),
            buildExprAst("'O\\'Rourke'")
    );
  }

@dai-chen
Copy link
Collaborator

Tested and I think this is already fixed in #696:

POST _plugins/_sql
{
  "query": """
    SELECT 'O\'Rourke'
  """
}
{
  "schema": [
    {
      "name": """'O\'Rourke'""",
      "type": "keyword"
    }
  ],
  "datarows": [
    [
      """O\'Rourke"""
    ]
  ],
  "total": 1,
  "size": 1,
  "status": 200
}

@dai-chen dai-chen moved this to Done in SQL Engineering Dec 15, 2022
@Yury-Fridlyand
Copy link
Collaborator

Fix for escape characters is coming in Bit-Quill#159. It is a breaking change, so it is targeted to 3.x branch.

acarbonetto pushed a commit that referenced this issue Jul 26, 2023
* Added support of timestamp/date/time using curly brackets (#297)

* added bracketed time/date/timestamp input, tests, and documentation

Signed-off-by: Matthew Wells <[email protected]>

* improved failing tests

Signed-off-by: Matthew Wells <[email protected]>

* simplified tests for checking for failure

Signed-off-by: Matthew Wells <[email protected]>

* fixed redundant tests and improved tests that should fail

Signed-off-by: Matthew Wells <[email protected]>

---------

Signed-off-by: Matthew Wells <[email protected]>
Yury-Fridlyand pushed a commit that referenced this issue Jul 28, 2023
…ets (#1908)

* Added support of timestamp/date/time using curly brackets (#1894)

* Added support of timestamp/date/time using curly brackets (#297)

* added bracketed time/date/timestamp input, tests, and documentation

Signed-off-by: Matthew Wells <[email protected]>

* improved failing tests

Signed-off-by: Matthew Wells <[email protected]>

* simplified tests for checking for failure

Signed-off-by: Matthew Wells <[email protected]>

* fixed redundant tests and improved tests that should fail

Signed-off-by: Matthew Wells <[email protected]>

---------

Signed-off-by: Matthew Wells <[email protected]>
(cherry picked from commit 1a7134b)

* fixed bad cherrypick merge conflict

Signed-off-by: Matthew Wells <[email protected]>

---------

Signed-off-by: Matthew Wells <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tdvt Tableau test framework
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants