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

IGNITE-13019 Fail on non-colocated join #8744

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ public class GridSqlQuerySplitter {
/** Whether partition extraction is possible. */
private final boolean canExtractPartitions;

/** Distributed joins flag. */
private final boolean distributedJoins;

/** Ignite logger. */
private final IgniteLogger log;

/** */
private final IdentityHashMap<GridSqlAst, GridSqlAlias> uniqueFromAliases = new IdentityHashMap<>();

Expand All @@ -144,11 +150,14 @@ public GridSqlQuerySplitter(
boolean collocatedGrpBy,
boolean distributedJoins,
boolean locSplit,
PartitionExtractor extractor
PartitionExtractor extractor,
IgniteLogger log
) {
this.paramsCnt = paramsCnt;
this.collocatedGrpBy = collocatedGrpBy;
this.extractor = extractor;
this.distributedJoins = distributedJoins;
this.log = log;

// Partitions *CANNOT* be extracted if:
// 1) Distributed joins are enabled (https://issues.apache.org/jira/browse/IGNITE-10971)
Expand Down Expand Up @@ -263,7 +272,8 @@ private static GridCacheTwoStepQuery split0(
collocatedGrpBy,
distributedJoins,
locSplit,
idx.partitionExtractor()
idx.partitionExtractor(),
log
);

// Normalization will generate unique aliases for all the table filters in FROM.
Expand Down Expand Up @@ -1263,11 +1273,14 @@ private void splitSelect(GridSqlAst parent, int childIdx) throws IgniteCheckedEx

setupParameters(map, mapQry, paramsCnt);

SqlAstTraverser traverser = new SqlAstTraverser(mapQry, distributedJoins, log);
traverser.traverse();

map.columns(collectColumns(mapExps));
map.sortColumns(mapQry.sort());
map.partitioned(SplitterUtils.hasPartitionedTables(mapQry));
map.hasSubQueries(SplitterUtils.hasSubQueries(mapQry));
map.hasOuterJoinReplicatedPartitioned(SplitterUtils.hasOuterJoinReplicatedPartitioned(mapQry.from()));
map.partitioned(traverser.hasPartitionedTables());
map.hasSubQueries(traverser.hasSubQueries());
map.hasOuterJoinReplicatedPartitioned(traverser.hasOuterJoinReplicatedPartitioned());

if (map.isPartitioned() && canExtractPartitions)
map.derivedPartitions(extractor.extract(mapQry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,35 +164,6 @@ public static boolean hasLeftJoin(GridSqlAst from) {
return false;
}

/**
* Checks whether the expression has an OUTER JOIN from replicated to partitioned.
*
* This is used to infer the `treatReplicatedAsPartitioned` flag
* to eventually pass it to {@link org.apache.ignite.spi.indexing.IndexingQueryFilterImpl}.
*
* @param from FROM expression.
* @return {@code true} if the expression has an OUTER JOIN from replicated to partitioned.
*/
public static boolean hasOuterJoinReplicatedPartitioned(GridSqlAst from) {
boolean isRightPartitioned = false;
while (from instanceof GridSqlJoin) {
GridSqlJoin join = (GridSqlJoin)from;

assert !(join.rightTable() instanceof GridSqlJoin);

isRightPartitioned = isRightPartitioned || hasPartitionedTables(join.rightTable());

if (join.isLeftOuter()) {
boolean isLeftPartitioned = hasPartitionedTables(join.leftTable());
return !isLeftPartitioned && isRightPartitioned;
}

from = join.leftTable();
}

return false;
}

/**
* @param ast Reduce query AST.
* @param rdcQry Reduce query string.
Expand Down