Skip to content

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

@joshuali925

Description

@joshuali925

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions