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

[BUG] [SQL] Group by on a subquery returns an error #308

Closed
joshuali925 opened this issue Nov 30, 2021 · 1 comment
Closed

[BUG] [SQL] Group by on a subquery returns an error #308

joshuali925 opened this issue Nov 30, 2021 · 1 comment
Assignees
Labels

Comments

@joshuali925
Copy link
Member

Describe the bug
from ODFE repo opendistro-for-elasticsearch/sql#662:

While applying a basic filter in PBID with direct query mode, the following query is generated

select `OriginCountry`
from 
(
    select `OriginCountry`
    from `kibana_sample_data_flights`
    where `OriginCountry` in ('AE', 'CA')
) as `ITBL`
group by `OriginCountry`
order by `OriginCountry`
limit 501

which returns an error as

{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "class com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to class com.alibaba.druid.sql.ast.statement.SQLJoinTableSource (com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource and com.alibaba.druid.sql.ast.statement.SQLJoinTableSource are in unnamed module of loader java.net.FactoryURLClassLoader @d5556bf)",
    "type": "ClassCastException"
  },
  "status": 503
}

image

@joshuali925 joshuali925 added the bug Something isn't working label Nov 30, 2021
@joshuali925 joshuali925 self-assigned this Nov 30, 2021
@joshuali925 joshuali925 changed the title [BUG] The query generated while applying a basic filter in Power BI Desktop with direct query mode returns an error [BUG] [SQL] Group by on a subquery returns an error Nov 30, 2021
@penghuo
Copy link
Collaborator

penghuo commented Jan 6, 2022

Currently, OpenSearch SQL doesn't support IN operator. https://github.com/opensearch-project/sql/blob/main/docs/user/dql/expressions.rst#comparison-operators

One workaround should be.

POST /_plugins/_sql
{
  "query": """select `OriginCountry` from (
    select `OriginCountry`
    from `opensearch_dashboards_sample_data_flights`
    where `OriginCountry` = 'AE' or  `OriginCountry` = 'CA') as `ITBL` group by `OriginCountry` order by `OriginCountry` limit 501"""
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants