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

Support for _routing field in SQL queries #339

Open
newUserForTesting opened this issue Dec 15, 2021 · 2 comments
Open

Support for _routing field in SQL queries #339

newUserForTesting opened this issue Dec 15, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@newUserForTesting
Copy link

Here is the relevant documentation for _routing field: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-routing-field.html

This is extremely useful for optimizing query performance for large ElasticSearch cluster.
Requesting to please provide support for _routing field for SQL queries. We really appreciate your help!

Thanks!

@newUserForTesting newUserForTesting added the enhancement New feature or request label Dec 15, 2021
@penghuo penghuo self-assigned this Jan 4, 2022
@penghuo
Copy link
Collaborator

penghuo commented Jan 4, 2022

Thanks for raising this!
Currently, only field defined in index mapping is used as identifier in sql query. _routing is a metafield which is not defined in index mapping, so _routing could not been used as identifier in sql query.

For example, following query will throw SemanticCheckException _routing is not defined.

SELECT age, balance 
FROM accounts 
WHERE _routing = 'user1'

I think one solution is to borrow pseudo columns concept to expose metadata field like _routing.

@newUserForTesting Can you elaborate on your use case to provide us some insights?

@acarbonetto
Copy link
Collaborator

Proposal: couchbase offers META() as a way to retrieve metadata fields in their n1ql syntax https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/indexing-meta-info.html.

We could consider coding something similar to SQL DSL that allows one to do:

SELECT age, balance
FROM accounts
WHERE META()._routing = 'user1

Yury-Fridlyand pushed a commit that referenced this issue Aug 16, 2023
* Spotless apply on PPL (#339)

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

* Update ppl/src/test/java/org/opensearch/sql/ppl/parser/AstExpressionBuilderTest.java

Co-authored-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>

---------

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>
Co-authored-by: Guian Gumpac <guian.gumpac@improving.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants