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

Resolve Alias Issues in Legacy SQL with Filters #2960

Merged

Conversation

aparajita31pandey
Copy link
Contributor

@aparajita31pandey aparajita31pandey commented Sep 1, 2024

Description

Alias query in legacy SQL which had filters to it didn't work . This diff addresses that issue. This diff derives index name from alias, for legacy sql queries having filters to it.

Before the change

curl -X POST "localhost:9200/_plugins/_sql" -H 'Content-Type: application/json' -d '{
  "query": "SELECT * FROM my-alias",
  "fetch_size": 1,
   "filter" : {
    "term" : {
      "field2" : "Sample keyword2"
    }
  }
}'
{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "Index type [my-alias] does not exist",
    "type": "IllegalArgumentException"
  },
  "status": 500
}

After the change:

curl -X POST "localhost:9200/_plugins/_sql" -H 'Content-Type: application/json' -d '{
  "query": "SELECT * FROM my-alias",
  "fetch_size": 1,
   "filter" : {
    "term" : {
      "another_field" : "hello"
    }
  }
}'
{
  "schema": [
    {
      "name": "new_field",
      "type": "text"
    },
    {
      "name": "another_field",
      "type": "keyword"
    }
  ],
  "total": 1,
  "datarows": [[
    "Some text",
    "hello"
  ]],
  "size": 1,
  "status": 200

Related Issues

Resolves #2912
#1398 #1412

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@aparajita31pandey aparajita31pandey changed the title Fixpagination alias WIP: Fixpagination alias Sep 1, 2024
@aparajita31pandey aparajita31pandey changed the title WIP: Fixpagination alias WIP: Fix Pagination alias on Legacy SQL Sep 1, 2024
@aparajita31pandey aparajita31pandey changed the title WIP: Fix Pagination alias on Legacy SQL Fix Pagination alias on Legacy SQL Sep 2, 2024
@aparajita31pandey aparajita31pandey changed the title Fix Pagination alias on Legacy SQL Resolve Alias Issues in Legacy SQL with Filters Sep 4, 2024
@ctellechea2001
Copy link

@aparajita31pandey Do you know when could be this PR reviewed and merged to fix this issue that we have reported?
#2912

@HabooshHaddad
Copy link

HabooshHaddad commented Sep 29, 2024

Hello ,
Is this going to be merged anytime soon ?

@LantaoJin
Copy link
Member

LantaoJin commented Oct 1, 2024

Thanks for your contribution, @aparajita31pandey could you add an IntegTest for the changes?
You can add an override method makeRequest for your test, ref

protected String makeRequest(String query, int fetch_size) {

@aparajita31pandey
Copy link
Contributor Author

@LantaoJin I have tested and added an IntegTest for the changes. Please take a look

LantaoJin
LantaoJin previously approved these changes Oct 4, 2024
@LantaoJin
Copy link
Member

@aparajita31pandey please fix the code style problem via run ./gradlew spotlessApply

@aparajita31pandey
Copy link
Contributor Author

@LantaoJin Updated the diff with ./gradlew spotlessApply

Copy link
Member

@LantaoJin LantaoJin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build failure is irrelevant, LGTM

@aparajita31pandey
Copy link
Contributor Author

aparajita31pandey commented Oct 4, 2024

@dai-chen @ykmr1224 @MaxKsyunz Can I get one more approval please?

Copy link
Collaborator

@MaxKsyunz MaxKsyunz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aparajita31pandey
Copy link
Contributor Author

Hey @LantaoJin , can you please help getting this diff merged ?

@LantaoJin LantaoJin merged commit 564ab60 into opensearch-project:main Oct 8, 2024
13 of 15 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 8, 2024
* Fix: Pagination of index aliases is not supported

Signed-off-by: Aparajita Pandey <[email protected]>

* fix: remove extra debug log

Signed-off-by: Aparajita Pandey <[email protected]>

* Integration testadded
Signed-off-by: Aparajita Pandey<[email protected]>

Signed-off-by: Aparajita Pandey <[email protected]>

* rollback change Signed-off-by: Aparajita Pandey<[email protected]>

Signed-off-by: Aparajita Pandey <[email protected]>

* Integration TestAdded Signed-off-by: Aparajita Pandey <[email protected]>

Signed-off-by: Aparajita Pandey <[email protected]>

* Integration TestAdded Signed-off-by: Aparajita Pandey <[email protected]>

Signed-off-by: Aparajita Pandey <[email protected]>

* SpotlessCheck Signed-off-by: Aparajita Pandey <[email protected]>

Signed-off-by: Aparajita Pandey <[email protected]>

---------

Signed-off-by: Aparajita Pandey <[email protected]>
(cherry picked from commit 564ab60)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Pagination of index aliases is not supported - Re-opened
5 participants