korlov42 commented on code in PR #2397:
URL: https://github.com/apache/ignite-3/pull/2397#discussion_r1291102021
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/PlanUtils.java:
##########
@@ -144,14 +144,33 @@ public static Mapping
computeAggFieldMapping(List<ImmutableBitSet> groupingSets)
}
}
- Mapping mapping = Mappings.create(MappingType.INVERSE_SURJECTION,
fieldIndices.length(), fieldIndices.cardinality());
+ return sortedValuesIndexMapping(fieldIndices);
+ }
+
+ /**
+ * Creates a mapping such that each value is replaced by its position in
the ordered list.
+ *
+ * <p>For example, for the following values {@code [2, 3, 5, 7, 9]} the
sorting positions
+ * will be {@code [0, 1, 2, 3, 4]}, the resulting mapping will be:
+ * <pre>
+ * 2 -> 0
+ * 3 -> 1
+ * 5 -> 2
+ * 7 -> 3
+ * 9 -> 4
+ * </pre>
+ *
+ * @param values Values to be mapped to its position in the ordered list.
+ */
+ public static Mapping sortedValuesIndexMapping(BitSet values) {
Review Comment:
well, we already have
`org.apache.ignite.internal.sql.engine.util.Commons#trimmingMapping`...
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rule/TableModifyConverterRule.java:
##########
@@ -71,8 +76,27 @@ protected PhysicalNode convert(RelOptPlanner planner,
RelMetadataQuery mq, Logic
IgniteTable igniteTable = relTable.unwrap(IgniteTable.class);
assert igniteTable != null;
+ IgniteDistribution distribution = igniteTable.distribution();
+
+ if (rel.getOperation() == Operation.DELETE) {
+ // To perform the delete, we need a row with key fields only.
+ // Input distribution contains the indexes of the key columns
according to the schema (i.e. for the full row).
+ // Here we adjusting distribution keys so that a row containing
only the key fields can be read.
+ BitSet keyFields = new BitSet();
+
+ for (int i = 0; i < igniteTable.descriptor().columnsCount(); i++) {
+ ColumnDescriptor column =
igniteTable.descriptor().columnDescriptor(i);
+
+ if (column.key()) {
+ keyFields.set(column.logicalIndex());
+ }
+ }
+
+ distribution =
distribution.apply(PlanUtils.sortedValuesIndexMapping(keyFields));
Review Comment:
the same, let's use
`org.apache.ignite.internal.sql.engine.util.Commons#trimmingMapping`
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/UpdatableTableImpl.java:
##########
@@ -71,6 +74,11 @@ public final class UpdatableTableImpl implements
UpdatableTable {
private final List<ColumnDescriptor> columnsOrderedByPhysSchema;
+ private final List<ColumnDescriptor> keyColumnsOrderedByPhysSchema;
+
+ /** Mapping of column indexes for a row containing only primary key
columns. */
Review Comment:
let's add a few details describing WHY do we need such mapping
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]