Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.calcite.plan.ConventionTraitDef;
import org.apache.calcite.plan.RelTraitDef;
import org.apache.calcite.rel.RelCollationTraitDef;
import org.apache.calcite.rel.core.Correlate;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlDdl;
Expand Down Expand Up @@ -145,8 +144,6 @@ public class CalciteQueryProcessor extends GridProcessorAdapter implements Query
// See Apache Calcite ticket for more information, assertion is incorrect.
// FRAMEWORK_CONFIG initialize SqlToRelConverter class. Assertions should be disabled before class initialization.
SqlToRelConverter.class.getClassLoader().setClassAssertionStatus(SqlToRelConverter.class.getName(), false);
// TODO Workaround for https://issues.apache.org/jira/browse/CALCITE-5421 and https://issues.apache.org/jira/browse/CALCITE-7034
Correlate.class.getClassLoader().setClassAssertionStatus(Correlate.class.getName(), false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ public abstract class MergeJoinNode<Row> extends AbstractNode<Row> {
*/
protected final boolean distributed;

/** Flag indicating that join is in finishing stage (one of the inputs are ended, no more rows will be produced). */
protected boolean finishing;

@zstan zstan Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to check this fix : revert all these changes and run : CorrelatesIntegrationTest#testCorrelatesCollision probably need to disable rules:
//NestedLoopJoinConverterRule.INSTANCE,
//HashJoinConverterRule.INSTANCE,
or simply run on master with commented rules

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also seems JoinBuffersExecutionTest need to be expanded somehow, cause it need to catch such a cases but it does not.


/**
* @param ctx Execution context.
* @param comp Join expression.
Expand Down Expand Up @@ -181,10 +178,10 @@ private void pushLeft(Row row) throws Exception {

waitingLeft--;

if (!finishing)
leftInBuf.add(row);
leftInBuf.add(row);

join();
if (waitingLeft == 0 && waitingRight <= 0)
join();
}

/** */
Expand All @@ -194,10 +191,10 @@ private void pushRight(Row row) throws Exception {

waitingRight--;

if (!finishing)
rightInBuf.add(row);
rightInBuf.add(row);

join();
if (waitingRight == 0 && waitingLeft <= 0)
join();
}

/** */
Expand All @@ -207,7 +204,8 @@ private void endLeft() throws Exception {

waitingLeft = NOT_WAITING;

join();
if (waitingRight <= 0)
join();
}

/** */
Expand All @@ -217,7 +215,8 @@ private void endRight() throws Exception {

waitingRight = NOT_WAITING;

join();
if (waitingLeft <= 0)
join();
}

/** */
Expand All @@ -241,27 +240,6 @@ protected boolean rightFinished(boolean withMaterialization) {
&& (!withMaterialization || rightMaterialization == null);
}

/** */
protected boolean checkJoinFinished() throws Exception {
if (!finishing) {
finishing = true;
leftInBuf.clear();
rightInBuf.clear();
rightMaterialization = null;
rightIdx = 0;
drainMaterialization = false;
}

if (!distributed || (waitingLeft == NOT_WAITING && waitingRight == NOT_WAITING)) {
requested = 0;
downstream().end();

return true;
}

return false;
}

/** */
protected void tryToRequestInputs() throws Exception {
if (waitingLeft == 0 && leftInBuf.size() <= HALF_BUF_SIZE)
Expand Down Expand Up @@ -417,8 +395,12 @@ else if (cmp > 0) {
inLoop = false;
}

if (requested > 0 && (leftFinished() || rightFinished(true)) && checkJoinFinished())
if (requested > 0 && (leftFinished() || rightFinished(true))) {
requested = 0;
downstream().end();

return;
}
Comment on lines +398 to +403

tryToRequestInputs();
}
Expand Down Expand Up @@ -571,8 +553,12 @@ else if (cmp > 0) {
inLoop = false;
}

if (requested > 0 && leftFinished() && checkJoinFinished())
if (requested > 0 && leftFinished()) {
requested = 0;
downstream().end();

return;
}

tryToRequestInputs();
}
Expand Down Expand Up @@ -737,8 +723,12 @@ else if (cmp > 0) {
inLoop = false;
}

if (requested > 0 && rightFinished(true) && checkJoinFinished())
if (requested > 0 && rightFinished(true)) {
requested = 0;
downstream().end();

return;
}

tryToRequestInputs();
}
Expand Down Expand Up @@ -942,8 +932,12 @@ else if (cmp > 0) {
inLoop = false;
}

if (requested > 0 && leftFinished() && rightFinished(true) && checkJoinFinished())
if (requested > 0 && leftFinished() && rightFinished(true)) {
requested = 0;
downstream().end();

return;
}

tryToRequestInputs();
}
Expand Down Expand Up @@ -998,8 +992,12 @@ else if (cmp > 0) {
inLoop = false;
}

if (requested > 0 && (leftFinished() || rightFinished(false)) && checkJoinFinished())
if (requested > 0 && (leftFinished() || rightFinished(false))) {
requested = 0;
downstream().end();

return;
}

tryToRequestInputs();
}
Expand Down Expand Up @@ -1057,8 +1055,12 @@ else if (cmp > 0) {
inLoop = false;
}

if (requested > 0 && leftFinished() && checkJoinFinished())
if (requested > 0 && leftFinished()) {
requested = 0;
downstream().end();

return;
}

tryToRequestInputs();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.apache.calcite.rex.RexSlot;
import org.apache.calcite.rex.RexVisitor;
import org.apache.calcite.rex.RexVisitorImpl;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.ignite.internal.processors.query.calcite.rel.ProjectableFilterableTableScan;
import org.jetbrains.annotations.Nullable;

Expand All @@ -61,8 +60,9 @@
*/
public class IgniteMdColumnOrigins implements MetadataHandler<BuiltInMetadata.ColumnOrigin> {
/** */
public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.COLUMN_ORIGIN.method, new IgniteMdColumnOrigins());
public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(
new IgniteMdColumnOrigins(), BuiltInMetadata.ColumnOrigin.Handler.class);

/** {@inheritDoc} */
@Override public MetadataDef<BuiltInMetadata.ColumnOrigin> getDef() {
Expand Down Expand Up @@ -369,15 +369,15 @@ private static Set<RelColumnOrigin> getMultipleColumns(RexNode rexNode, RelNode
final Set<RelColumnOrigin> set = new HashSet<>();

final RexVisitor<Void> visitor = new RexVisitorImpl<Void>(true) {
@Override public Void visitInputRef(RexInputRef inputRef) {
Set<RelColumnOrigin> inputSet = mq.getColumnOrigins(input, inputRef.getIndex());
@Override public Void visitInputRef(RexInputRef inputRef) {
Set<RelColumnOrigin> inputSet = mq.getColumnOrigins(input, inputRef.getIndex());

if (inputSet != null)
set.addAll(inputSet);
if (inputSet != null)
set.addAll(inputSet);

return null;
}
};
return null;
}
};

rexNode.accept(visitor);

Expand Down
Loading
Loading