You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by tl...@apache.org on 2021/05/28 15:54:20 UTC
[ignite] branch sql-calcite updated: IGNITE-14792 SQL Calcite. Fix
build UPDATE when new column value depends on the old (#9134)
This is an automated email from the ASF dual-hosted git repository.
tledkov pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/sql-calcite by this push:
new cb0cfa0 IGNITE-14792 SQL Calcite. Fix build UPDATE when new column value depends on the old (#9134)
cb0cfa0 is described below
commit cb0cfa0312ca2cdec432e3070c3b6849056d6a80
Author: korlov42 <ko...@gridgain.com>
AuthorDate: Fri May 28 18:53:59 2021 +0300
IGNITE-14792 SQL Calcite. Fix build UPDATE when new column value depends on the old (#9134)
---
.../processors/query/calcite/schema/TableDescriptor.java | 2 +-
.../processors/query/calcite/schema/TableDescriptorImpl.java | 10 ++++------
.../query/calcite/integration/TableDmlIntegrationTest.java | 4 ++--
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptor.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptor.java
index 3adfbfb..abc7dcf 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptor.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptor.java
@@ -83,7 +83,7 @@ public interface TableDescriptor extends RelProtoDataType, InitializerExpression
}
/**
- * Returns row type of internal fields (either virtual or real) only.
+ * Returns row type including effectively virtual fields.
*
* @param factory Type factory.
* @return Row type for SELECT operation.
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptorImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptorImpl.java
index da89cca..01af95e 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptorImpl.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptorImpl.java
@@ -27,6 +27,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
+
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.rel.core.TableModify;
import org.apache.calcite.rel.type.RelDataType;
@@ -218,11 +219,6 @@ public class TableDescriptorImpl extends NullInitializerExpressionFactory
}
/** {@inheritDoc} */
- @Override public RelDataType selectForUpdateRowType(IgniteTypeFactory factory) {
- return rowType(factory, ImmutableBitSet.of(keyField, valField));
- }
-
- /** {@inheritDoc} */
@Override public GridCacheContext cacheContext() {
return cacheInfo.cacheContext();
}
@@ -451,12 +447,14 @@ public class TableDescriptorImpl extends NullInitializerExpressionFactory
Object key = Objects.requireNonNull(handler.get(QueryUtils.KEY_COL, row));
Object val = clone(Objects.requireNonNull(handler.get(QueryUtils.VAL_COL, row)));
+ int offset = descriptorsMap.size();
+
for (int i = 0; i < updateColList.size(); i++) {
final ColumnDescriptor desc = Objects.requireNonNull(descriptorsMap.get(updateColList.get(i)));
assert !desc.key();
- Object fieldVal = handler.get(i + 2, row);
+ Object fieldVal = handler.get(i + offset, row);
if (desc.field())
desc.set(val, TypeUtils.fromInternal(ectx, fieldVal, desc.storageType()));
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java
index 3091dba..42bf2e6 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java
@@ -233,7 +233,7 @@ public class TableDmlIntegrationTest extends GridCommonAbstractTest {
assertEqualsCollections(F.asList(0, 0, "Igor", 1), row);
- query = engine.query(null, "PUBLIC", "UPDATE DEVELOPER d SET name = 'Roman' WHERE id = ?", 0);
+ query = engine.query(null, "PUBLIC", "UPDATE DEVELOPER d SET name = name || 'Roman' WHERE id = ?", 0);
assertEquals(1, query.size());
@@ -251,7 +251,7 @@ public class TableDmlIntegrationTest extends GridCommonAbstractTest {
assertNotNull(row);
- assertEqualsCollections(F.asList(0, 0, "Roman", 1), row);
+ assertEqualsCollections(F.asList(0, 0, "IgorRoman", 1), row);
query = engine.query(null, "PUBLIC", "DELETE FROM DEVELOPER WHERE id = ?", 0);