You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Subquery aliasing doesn't work with ` characters #550
I can reproduce the issue by ODS sample data in playground:
POST _plugins/_sql
{
"query": """
SELECT
`a`.`Origin` AS `Origin`,
AVG(`AvgTicketPrice`) AS `avgPrice`
FROM (
SELECT `Origin`, `AvgTicketPrice`
FROM `opensearch_dashboards_sample_data_flights`
WHERE `FlightDelay` = True
) AS `a`
GROUP BY `a`.`Origin`
"""
}
{
"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 @55e42684)",
"type": "ClassCastException"
},
"status": 503
}
I suspect this issue is the root cause of other subquery issue:
Analyzing failure caused fall back to legacy which throws ClassCastException due to unsupported FROM subquery with aggregation.
The detailed error is: "The qualifier [a] of qualified name [a.Origin] must be an field name, index name or its alias". The reason may be visitSubqueryRelation doesn't push alias name to symbol table.
Activity
dai-chen commentedon Dec 15, 2022
I can reproduce the issue by ODS sample data in playground:
I suspect this issue is the root cause of other subquery issue:
Because I tested complicated subquery in FROM clause without back quoted alias, I see no problem and all outer grouping and sorting can be done in memory. Probably we can update the limitation doc: https://github.com/opensearch-project/sql/blob/main/docs/user/limitations/limitations.rst#subqueries-in-the-from-clause
dai-chen commentedon Dec 15, 2022
Analyzing failure caused fall back to legacy which throws ClassCastException due to unsupported FROM subquery with aggregation.
The detailed error is: "The qualifier [a] of qualified name [a.Origin] must be an field name, index name or its alias". The reason may be visitSubqueryRelation doesn't push alias name to symbol table.
dai-chen commentedon Dec 15, 2022
It seems the back quoted alias name is pushed to symbol table rather than unquoted: