Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4b959cc
IGNITE-28899 Calcite. Fix litmus error during join
zstan Jul 16, 2026
e6b318b
fix after review
zstan Aug 25, 2026
1322ea1
fix after review changes from IGNITE-25129
zstan Aug 26, 2026
721c2f4
change IgniteNestedLoopJoin cost after review
zstan Aug 26, 2026
5e7216b
concreete getRowCount for IgniteCorrelatedNestedLoopJoin
zstan Aug 27, 2026
0e00b1b
add test
zstan Aug 27, 2026
9455947
CNLJ test ok
zstan Aug 27, 2026
ba1fcea
assertionOnDeserialization fix
zstan Aug 27, 2026
5dd9336
add litmus comment
zstan Aug 28, 2026
b3999a5
Merge branch 'master' into ignite-28899
zstan Sep 10, 2026
cff9d91
Merge branch 'master' into ignite-28899
zstan Sep 11, 2026
1e78f11
fix import
zstan Sep 14, 2026
6025901
cl fix
Sep 14, 2026
2c5c8cb
interm
zstan Sep 14, 2026
f821da4
self review
zstan Sep 14, 2026
f844134
self review cl fix
Sep 14, 2026
4850afd
mdcount fix
zstan Sep 15, 2026
1cf3a54
style check
zstan Sep 15, 2026
faecb58
fix test
zstan Sep 16, 2026
14780e1
revert test
zstan Sep 16, 2026
cffdb81
unused import
zstan Sep 17, 2026
c914121
Merge branch 'master' into ignite-28899
zstan Oct 19, 2026
e29bd0b
junit5 related fix
zstan Oct 20, 2026
6763848
fix after review 1
zstan Oct 23, 2026
b2e2306
fix
zstan Oct 23, 2026
0e80418
fix after review 2
zstan Oct 23, 2026
f2b2705
fix after review 3
zstan Oct 23, 2026
038cf37
litmus test fix, all other tests are ok
zstan Oct 23, 2026
5a3b459
IgniteMd* reflection methods fix
zstan Oct 23, 2026
d515947
full join estimation changes
zstan Oct 23, 2026
0c2c568
postFiltrationAdjustment fix
zstan Oct 23, 2026
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like we can remove previous workaraund too

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.

done

Correlate.class.getClassLoader().setClassAssertionStatus(Correlate.class.getName(), false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;
import java.util.Set;
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.plan.volcano.RelSubset;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Aggregate;
import org.apache.calcite.rel.core.AggregateCall;
Expand Down Expand Up @@ -51,8 +52,10 @@
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.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.mapping.Mappings;
import org.apache.ignite.internal.processors.query.calcite.rel.ProjectableFilterableTableScan;
import org.apache.ignite.internal.processors.query.calcite.util.Commons;
import org.jetbrains.annotations.Nullable;

/**
Expand All @@ -61,8 +64,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 @@ -261,27 +265,45 @@ public class IgniteMdColumnOrigins implements MetadataHandler<BuiltInMetadata.Co
int iOutputColumn
) {
if (rel.projects() != null) {
RexNode proj = rel.projects().get(iOutputColumn);
Set<RexSlot> sources = new HashSet<>();
RexNode node = rel.projects().get(iOutputColumn);
if (node instanceof RexInputRef) {
RexInputRef inputRef = (RexInputRef)node;
iOutputColumn = inputRef.getIndex();
}
else {
Set<RexSlot> sources = new HashSet<>();

getOperands(proj, RexSlot.class, sources);
getOperands(node, RexSlot.class, sources);

boolean derived = sources.size() > 1;
Set<RelColumnOrigin> res = new HashSet<>();
boolean derived = sources.size() > 1;
Set<RelColumnOrigin> res = new HashSet<>();

for (RexSlot slot : sources) {
if (slot instanceof RexLocalRef) {
RelColumnOrigin slotOrigin = rel.columnOriginsByRelLocalRef(slot.getIndex());
for (RexSlot slot : sources) {
if (slot instanceof RexLocalRef) {
RelColumnOrigin slotOrigin = rel.columnOriginsByRelLocalRef(slot.getIndex());

res.add(new RelColumnOrigin(slotOrigin.getOriginTable(), slotOrigin.getOriginColumnOrdinal(),
derived));
res.add(new RelColumnOrigin(slotOrigin.getOriginTable(), slotOrigin.getOriginColumnOrdinal(),
derived));
}
}

return res;
}
}

ImmutableBitSet requiredColumns = rel.requiredColumns();
RelOptTable table = rel.getTable();

if (requiredColumns != null) {
Mappings.TargetMapping trimming = Commons.projectedMapping(requiredColumns, table.getRowType().getFieldCount());

iOutputColumn = trimming.getSourceOpt(iOutputColumn);

return res;
if (iOutputColumn == -1)
return null;
}

return Collections.singleton(rel.columnOriginsByRelLocalRef(iOutputColumn));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What the difference with the current implementation?
Let's keep it as is, but replace requiredColumns().toArray()[colIdx] with requiredColumns().indexOf(colIdx) in columnOriginsByRelLocalRef for little optimization.

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.

indexOf is not identical to toArray()[colIdx] but ok, I fix it

return Set.of(new RelColumnOrigin(table, iOutputColumn, false));
}

/**
Expand All @@ -303,6 +325,12 @@ private <T> void getOperands(RexNode rn, Class<T> cls, Set<T> res) {
}
}

/** Provides column origin for Subset relation. */
public @Nullable Set<RelColumnOrigin> getColumnOrigins(RelSubset rel,
RelMetadataQuery mq, int outputColumn) {
return mq.getColumnOrigins(rel.stripped(), outputColumn);
}

/**
* Catch-all rule when none of the others apply.
*
Expand Down Expand Up @@ -369,15 +397,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