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/02/18 10:53:18 UTC
[ignite] branch sql-calcite updated: IGNITE-14148 SQL. Calcite: fix
map fragment for replicated group (#8805)
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 195280f IGNITE-14148 SQL. Calcite: fix map fragment for replicated group (#8805)
195280f is described below
commit 195280f48910446383a90a4b2e6dda3975e105b1
Author: korlov42 <ko...@gridgain.com>
AuthorDate: Thu Feb 18 13:52:51 2021 +0300
IGNITE-14148 SQL. Calcite: fix map fragment for replicated group (#8805)
---
.../query/calcite/schema/TableDescriptorImpl.java | 2 +-
.../query/calcite/CalciteQueryProcessorTest.java | 42 ++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
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 5ec8b73..08d895f 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
@@ -499,7 +499,7 @@ public class TableDescriptorImpl extends NullInitializerExpressionFactory
private ColocationGroup replicatedGroup(@NotNull AffinityTopologyVersion topVer) {
GridDhtPartitionTopology top = cctx.topology();
- List<ClusterNode> nodes = cctx.discovery().discoCache(topVer).cacheGroupAffinityNodes(cctx.cacheId());
+ List<ClusterNode> nodes = cctx.discovery().discoCache(topVer).cacheGroupAffinityNodes(cctx.groupId());
List<UUID> nodes0;
if (!top.rebalanceFinished(topVer)) {
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
index b92c4e0..a595511 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.query.calcite;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -73,6 +74,38 @@ public class CalciteQueryProcessorTest extends GridCommonAbstractTest {
}
}
+ /**
+ * Test verifies that replicated cache with specified cache group
+ * could be properly mapped on server nodes.
+ */
+ @Test
+ public void queryOverReplCacheGroup() {
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("ID", Integer.class.getName());
+ fields.put("VAL", String.class.getName());
+
+ IgniteCache<Integer, String> cache = client.getOrCreateCache(new CacheConfiguration<Integer, String>()
+ .setGroupName("SOME_GROUP")
+ .setName("TBL")
+ .setSqlSchema("PUBLIC")
+ .setQueryEntities(F.asList(new QueryEntity(Integer.class, String.class).setTableName("TBL")
+ .setKeyFieldName("ID")
+ .setFields(fields)
+ .setValueFieldName("VAL")
+ ))
+ .setCacheMode(CacheMode.REPLICATED)
+ );
+
+ cache.put(1, "1");
+ cache.put(2, "2");
+
+ assertQuery(client, "select id, val from tbl")
+ .returns(1, "1")
+ .returns(2, "2")
+ .check();
+ }
+
/** */
@Test
public void testCountWithJoin() throws Exception {
@@ -899,4 +932,13 @@ public class CalciteQueryProcessorTest extends GridCommonAbstractTest {
this.name = name;
}
}
+
+ /** */
+ private QueryChecker assertQuery(IgniteEx ignite, String qry) {
+ return new QueryChecker(qry) {
+ @Override protected QueryEngine getEngine() {
+ return Commons.lookupComponent(ignite.context(), QueryEngine.class);
+ }
+ };
+ }
}