You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Sviridov Aleksey Konstantinovich (Jira)" <ji...@apache.org> on 2022/11/11 05:27:00 UTC
[jira] [Commented] (IGNITE-5359) Non-collocated SQL subqueries return wrong results.
[ https://issues.apache.org/jira/browse/IGNITE-5359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17632077#comment-17632077 ]
Sviridov Aleksey Konstantinovich commented on IGNITE-5359:
----------------------------------------------------------
Hi all! Faced this problem and for me its decision became critical. I studied the indexing module and found that subqueries are automatically converted to joins, but when checking the possibility of such a transformation, it always returned false.
In the GridSubqueryJoinOptimizer class, the private static boolean isUniqueIndexExists method checks whether all used fields are indexed, and also asks if the index is unique.
First, the cols.containsAll(Arrays.asList(idx.getColumns()))) method didn't work properly and always returned false.
Second, I discovered that the unique field of the IndexType class is never set to true.
By redoing this method, I got the correct execution of nested queries in parallelism.
private static boolean isUniqueIndexExists(Collection<GridSqlColumn> gridCols, GridSqlTable tbl) {
Set<Column> cols = gridCols.stream().map(GridSqlColumn::column).collect(Collectors.toSet());
for (Index idx : tbl.dataTable().getIndexes()) {
int r = 0;
for (var col:cols) {
for (var idndex:idx.getColumns()) {
if (idndex.equals(col)) r++;
}
}
if (r == cols.size()) {
return true;
}
}
return false;
}
> Non-collocated SQL subqueries return wrong results.
> ---------------------------------------------------
>
> Key: IGNITE-5359
> URL: https://issues.apache.org/jira/browse/IGNITE-5359
> Project: Ignite
> Issue Type: Bug
> Components: sql
> Affects Versions: 2.0
> Reporter: Andrey Mashenkov
> Priority: Critical
> Labels: sql-engine
> Attachments: JoinWithAggr.java
>
>
> PFA repro attached.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)