lowka commented on code in PR #1798:
URL: https://github.com/apache/ignite-3/pull/1798#discussion_r1146303663
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rule/TableModifyConverterRule.java:
##########
@@ -48,12 +67,63 @@ public TableModifyConverterRule() {
@Override
protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq,
LogicalTableModify rel) {
RelOptCluster cluster = rel.getCluster();
+ RelOptTable relTable = rel.getTable();
+ IgniteTable igniteTable = relTable.unwrap(IgniteTable.class);
+ assert igniteTable != null;
+
RelTraitSet traits = cluster.traitSetOf(IgniteConvention.INSTANCE)
- .replace(IgniteDistributions.single())
+ .replace(igniteTable.distribution())
.replace(RelCollations.EMPTY);
+
RelNode input = convert(rel.getInput(), traits);
- return new IgniteTableModify(cluster, traits, rel.getTable(), input,
+ IgniteTableModify tableModify = new IgniteTableModify(cluster, traits,
relTable, input,
rel.getOperation(), rel.getUpdateColumnList(),
rel.getSourceExpressionList(), rel.isFlattened());
+
+ if (igniteTable.distribution().equals(IgniteDistributions.single())) {
+ return tableModify;
+ } else {
+ return createAggregate(tableModify, cluster);
+ }
+ }
+
+ private static PhysicalNode createAggregate(IgniteTableModify tableModify,
RelOptCluster cluster) {
+
+ RelTraitSet inTrait = cluster.traitSetOf(IgniteConvention.INSTANCE);
+ RelTraitSet outTrait = cluster.traitSetOf(IgniteConvention.INSTANCE);
+
+ RelDataType rowType = tableModify.getRowType();
+ RelDataTypeFactory typeFactory = cluster.getTypeFactory();
+ RelDataType sumType =
typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.DECIMAL),
true);
Review Comment:
@korlov42 This is not possible to use
`org.apache.calcite.rel.type.RelDataTypeSystem#deriveSumType` since this method
is going to derive an incorrect type and that is going to cause a type
difference assertion to fire.
I am going to add a comment that clarifies this.
--
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]