You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2021/09/17 06:26:21 UTC

[ignite] branch master updated: IGNITE-15263 Fix QuerySqlField.alias for affinity field - Fixes #9338.

This is an automated email from the ASF dual-hosted git repository.

ivandasch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new f7d3410  IGNITE-15263 Fix QuerySqlField.alias for affinity field - Fixes #9338.
f7d3410 is described below

commit f7d3410f794b39db696c4dcadc57ea8735fc62b2
Author: Maksim Timonin <ti...@gmail.com>
AuthorDate: Fri Sep 17 09:25:25 2021 +0300

    IGNITE-15263 Fix QuerySqlField.alias for affinity field - Fixes #9338.
    
    Signed-off-by: Ivan Daschinsky <iv...@apache.org>
---
 .../internal/processors/query/QueryUtils.java      |   4 +-
 .../processors/cache/AffinityAliasKeyTest.java     | 104 ++++++
 .../twostep/AbstractPartitionPruningBaseTest.java  | 161 ++++++++-
 .../twostep/DmlSelectPartitionPruningSelfTest.java |   9 +-
 .../h2/twostep/JoinPartitionPruningSelfTest.java   | 345 ++++---------------
 .../JoinQueryEntityPartitionPruningSelfTest.java   | 367 +++++++++++++++++++++
 .../twostep/MvccDmlPartitionPruningSelfTest.java   |   9 +-
 .../sqltests/CheckWarnJoinPartitionedTables.java   |  42 +++
 .../IgniteBinaryCacheQueryTestSuite.java           |   4 +
 9 files changed, 754 insertions(+), 291 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
index 9b4449e..502edfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
@@ -555,7 +555,7 @@ public class QueryUtils {
                         String affField0 = field.name();
 
                         if (!F.isEmpty(qryEntity.getKeyFields()) && qryEntity.getKeyFields().contains(affField0)) {
-                            affField = affField0;
+                            affField = desc.aliases().getOrDefault(affField0, affField0);
 
                             if (!escape)
                                 affField = normalizeObjectName(affField, false);
@@ -578,6 +578,8 @@ public class QueryUtils {
                     ((GridCacheDefaultAffinityKeyMapper)keyMapper).affinityKeyPropertyName(desc.keyClass());
 
                 if (affField != null) {
+                    affField = desc.aliases().getOrDefault(affField, affField);
+
                     if (!escape)
                         affField = normalizeObjectName(affField, false);
 
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityAliasKeyTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityAliasKeyTest.java
new file mode 100644
index 0000000..67108d2
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityAliasKeyTest.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+import org.apache.ignite.cache.query.FieldsQueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/** */
+@RunWith(Parameterized.class)
+public class AffinityAliasKeyTest extends GridCommonAbstractTest {
+    /** */
+    private static final String PERSON_CACHE = "PERSON";
+
+    /** */
+    private static IgniteEx ignite;
+
+    /** */
+    @Parameterized.Parameter
+    public boolean sqlEscape;
+
+    /** */
+    @Parameterized.Parameters(name = "escape = {0}")
+    public static Object[] params() {
+        return new Object[] { false, true };
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+            .setCacheConfiguration();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        ignite = startGrid();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        ignite.destroyCache(PERSON_CACHE);
+    }
+
+    /** */
+    @Test
+    public void testAliasAffinityKeyForIndexedTypes() {
+        IgniteCache<PersonKey, Object> cache = ignite.createCache(new CacheConfiguration<PersonKey, Object>()
+            .setName(PERSON_CACHE)
+            .setSqlEscapeAll(sqlEscape)
+            .setIndexedTypes(PersonKey.class, Object.class));
+
+        checkAffinityColumnName(cache);
+    }
+
+    /** */
+    private void checkAffinityColumnName(IgniteCache<PersonKey, Object> cache) {
+        String expAffColName = sqlEscape ? "city_id" : "CITY_ID";
+
+        try (FieldsQueryCursor<List<?>> cursor = cache.query(
+            new SqlFieldsQuery("select AFFINITY_KEY_COLUMN from sys.tables where cache_name = '" + PERSON_CACHE + "'"))
+        ) {
+            List<List<?>> res = cursor.getAll();
+
+            assertEquals(1, res.size());
+            assertEquals(1, res.get(0).size());
+            assertEquals(expAffColName, res.get(0).get(0));
+        }
+    }
+
+    /** */
+    public static class PersonKey {
+        /** Field with alias set as an affinity key. */
+        @QuerySqlField(name = "city_id")
+        @AffinityKeyMapped
+        private int cityId;
+    }
+}
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractPartitionPruningBaseTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractPartitionPruningBaseTest.java
index 2628d65..3adc8aa 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractPartitionPruningBaseTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/AbstractPartitionPruningBaseTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.query.h2.twostep;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -27,10 +28,18 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheKeyConfiguration;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.DataRegionConfiguration;
 import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -45,11 +54,15 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.query.QueryUtils.DFLT_SCHEMA;
 
 /**
  * Base class for partition pruning tests.
  */
-@SuppressWarnings("deprecation")
+@RunWith(Parameterized.class)
 public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstractTest {
     /** Number of intercepted requests. */
     private static final AtomicInteger INTERCEPTED_REQS = new AtomicInteger();
@@ -72,6 +85,10 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
     /** Client node name. */
     private static final String CLI_NAME = "cli";
 
+    /** Whether the test table is created with SQL or QueryEntity API. */
+    @Parameterized.Parameter
+    public boolean createTableWithSql;
+
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
         super.beforeTestsStarted();
@@ -84,7 +101,7 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
 
         startClientGrid(getConfiguration(CLI_NAME));
 
-        client().cluster().active(true);
+        client().cluster().state(ClusterState.ACTIVE);
     }
 
     /** {@inheritDoc} */
@@ -138,7 +155,10 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
      * @param cols Columns.
      */
     protected void createPartitionedTable(boolean mvcc, String name, Object... cols) {
-        createTable0(name, false, mvcc, cols);
+        if (createTableWithSql)
+            createTable0(name, false, mvcc, cols);
+        else
+            createCacheTable(name, false, mvcc, cols);
     }
 
     /**
@@ -159,7 +179,10 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
      * @param cols Columns.
      */
     protected void createReplicatedTable(boolean mvcc, String name, Object... cols) {
-        createTable0(name, true, mvcc, cols);
+        if (createTableWithSql)
+            createTable0(name, true, mvcc, cols);
+        else
+            createCacheTable(name, true, mvcc, cols);
     }
 
     /**
@@ -178,7 +201,7 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
 
         StringBuilder sql = new StringBuilder("CREATE TABLE ").append(name).append("(");
         for (Object col : cols) {
-            Column col0 = col instanceof Column ? (Column)col : new Column((String)col, false, false);
+            Column col0 = col instanceof Column ? (Column)col : new Column((String)col);
 
             sql.append(col0.name()).append(" VARCHAR, ");
 
@@ -228,6 +251,68 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
     }
 
     /**
+     * Create table with the QueryEntity API.
+     *
+     * @param name Name.
+     * @param replicated Replicated table flag.
+     * @param mvcc MVCC flag.
+     * @param cols Columns.
+     */
+    private void createCacheTable(String name, boolean replicated, boolean mvcc, Object... cols) {
+        QueryEntity e = new QueryEntity()
+            .setValueType(name)
+            .setTableName(name);
+
+        List<String> pkCols = new ArrayList<>();
+
+        String affCol = null;
+
+        for (Object col : cols) {
+            Column col0 = col instanceof Column ? (Column)col : new Column((String)col);
+
+            e.addQueryField(col0.name, String.class.getName(), col0.alias);
+
+            if (col0.pk())
+                pkCols.add(col0.name());
+
+            if (col0.affinity()) {
+                if (affCol != null)
+                    throw new IllegalStateException("Only one affinity column is allowed: " + col0.name());
+
+                affCol = col0.name();
+
+                pkCols.add(affCol);
+            }
+        }
+
+        if (pkCols.isEmpty())
+            throw new IllegalStateException("No PKs!");
+
+        e.setKeyFields(new HashSet<>(pkCols));
+
+        if (pkCols.size() == 1)
+            e.setKeyFieldName(pkCols.get(0));
+
+        String keyTypeName = pkCols.size() == 1 ? String.class.getName() : name + "_key";
+
+        e.setKeyType(keyTypeName);
+
+        CacheConfiguration<?, ?> ccfg = new CacheConfiguration<>()
+            .setName(name)
+            .setSqlSchema(DFLT_SCHEMA)
+            .setAtomicityMode(mvcc ? CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT : CacheAtomicityMode.TRANSACTIONAL)
+            .setCacheMode(replicated ? CacheMode.REPLICATED : CacheMode.PARTITIONED)
+            .setQueryEntities(Collections.singletonList(e));
+
+        if (affCol != null)
+            ccfg.setKeyConfiguration(new CacheKeyConfiguration()
+                .setTypeName(keyTypeName)
+                .setAffinityKeyFieldName(affCol));
+
+        client().createCache(ccfg);
+    }
+
+    /**
      * Execute query with all possible combinations of argument placeholders.
      *
      * @param sql SQL.
@@ -498,11 +583,39 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
     }
 
     /**
+     * @param table Table name.
+     * @param cols Number of columns for this table.
+     * @param until Inclusive upper boundary for inserting data.
+     */
+    protected void fillTable(String table, int cols, int until) {
+        String sql = "INSERT INTO " + table + " VALUES ("
+            + IntStream.range(0, cols).mapToObj(i -> "?").collect(Collectors.joining(","))
+            + ")";
+
+        for (int i = 1; i <= until; i++) {
+            int v = i;
+
+            Object[] arr = IntStream.range(0, cols).mapToObj(c -> v).toArray();
+
+            executeSql(sql, arr);
+        }
+    }
+
+    /**
      * @param name Name.
      * @return PK column.
      */
     public Column pkColumn(String name) {
-        return new Column(name, true, false);
+        return new Column(name, null, true, false);
+    }
+
+    /**
+     * @param name Name.
+     * @param alias Alias.
+     * @return PK column.
+     */
+    public Column pkColumn(String name, String alias) {
+        return new Column(name, alias, true, false);
     }
 
     /**
@@ -510,7 +623,16 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
      * @return Affintiy column.
      */
     public Column affinityColumn(String name) {
-        return new Column(name, true, true);
+        return new Column(name, null, true, true);
+    }
+
+    /**
+     * @param name Name.
+     * @param alias Alias.
+     * @return Affintiy column.
+     */
+    public Column affinityColumn(String name, String alias) {
+        return new Column(name, alias, true, true);
     }
 
     /**
@@ -520,6 +642,9 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
         /** Name. */
         private final String name;
 
+        /** Alias. */
+        private final String alias;
+
         /** PK. */
         private final boolean pk;
 
@@ -533,13 +658,26 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
          * @param pk PK flag.
          * @param aff Affinity flag.
          */
-        public Column(String name, boolean pk, boolean aff) {
+        public Column(String name, String alias, boolean pk, boolean aff) {
             this.name = name;
+            this.alias = alias;
             this.pk = pk;
             this.aff = aff;
         }
 
         /**
+         * Constructor.
+         *
+         * @param name Name.
+         */
+        public Column(String name) {
+            this.name = name;
+            alias = null;
+            pk = false;
+            aff = false;
+        }
+
+        /**
          * @return Name.
          */
         public String name() {
@@ -547,6 +685,13 @@ public abstract class AbstractPartitionPruningBaseTest extends GridCommonAbstrac
         }
 
         /**
+         * @return Alias.
+         */
+        public String alias() {
+            return alias;
+        }
+
+        /**
          * @return PK flag.
          */
         public boolean pk() {
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DmlSelectPartitionPruningSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DmlSelectPartitionPruningSelfTest.java
index ce7fec6..fc6d000 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DmlSelectPartitionPruningSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DmlSelectPartitionPruningSelfTest.java
@@ -20,12 +20,13 @@ package org.apache.ignite.internal.processors.query.h2.twostep;
 import java.util.List;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.util.typedef.F;
 import org.junit.Test;
+import org.junit.runners.Parameterized;
 
 /**
  * Tests for use partition pruning at the SELECT step of the UPDATE/DELETE statements execution.
  */
-@SuppressWarnings("deprecation")
 public class DmlSelectPartitionPruningSelfTest extends AbstractPartitionPruningBaseTest {
     /** Rows count for test tables. */
     private static final int ROWS = 10;
@@ -33,6 +34,12 @@ public class DmlSelectPartitionPruningSelfTest extends AbstractPartitionPruningB
     /** Recreate tables before each test statement. */
     private boolean recreateTables;
 
+    /** */
+    @Parameterized.Parameters(name = "createWithSql = {0}")
+    public static List<?> params() {
+        return F.asList(false, true);
+    }
+
     /**
      * Test UPDATE statement.
      */
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/JoinPartitionPruningSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/JoinPartitionPruningSelfTest.java
index 9315f2b..27331c8 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/JoinPartitionPruningSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/JoinPartitionPruningSelfTest.java
@@ -17,26 +17,16 @@
 
 package org.apache.ignite.internal.processors.query.h2.twostep;
 
-import java.util.Collections;
 import java.util.List;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.cache.CacheKeyConfiguration;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.QueryEntity;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.internal.util.typedef.F;
 import org.junit.Test;
+import org.junit.runners.Parameterized;
 
 /**
  * Tests for join partition pruning.
  */
-@SuppressWarnings("deprecation")
 public class JoinPartitionPruningSelfTest extends AbstractPartitionPruningBaseTest {
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
@@ -45,34 +35,81 @@ public class JoinPartitionPruningSelfTest extends AbstractPartitionPruningBaseTe
         clearIoState();
     }
 
+    /** */
+    @Parameterized.Parameters(name = "createWithSql = {0}")
+    public static List<?> params() {
+        return F.asList(true, false);
+    }
+
     /**
-     * Test simple join.
+     * Test PK only join.
      */
     @Test
-    public void testSimpleJoin() {
+    public void testPkOnlyJoin() {
         createPartitionedTable("t1",
             pkColumn("k1"),
             "v2");
 
         createPartitionedTable("t2",
             pkColumn("k1"),
-            affinityColumn("ak2"),
-            "v3");
+            "v2");
+
+        fillTable("t1", 2, 5);
+        fillTable("t2", 2, 5);
+
+        // Key (not alias).
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.k1 WHERE t1.k1 = ?",
+            (res) -> {
+                assertPartitions(
+                    partition("t1", "1")
+                );
+                assertEquals(1, res.size());
+                assertEquals("1", res.get(0).get(0));
+            },
+            "1"
+        );
 
-        executeSql("INSERT INTO t1 VALUES ('1', '1')");
-        executeSql("INSERT INTO t2 VALUES ('1', '1', '1')");
+        // Key (alias).
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.k1 WHERE t1._KEY = ?",
+            (res) -> {
+                assertPartitions(
+                    partition("t1", "2")
+                );
+                assertEquals(1, res.size());
+                assertEquals("2", res.get(0).get(0));
+            },
+            "2"
+        );
 
-        executeSql("INSERT INTO t1 VALUES ('2', '2')");
-        executeSql("INSERT INTO t2 VALUES ('2', '2', '2')");
+        // Non-affinity key.
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.k1 WHERE t2.k1 = ?",
+            (res) -> {
+                assertPartitions(
+                    partition("t1", "3")
+                );
+                assertEquals(1, res.size());
+                assertEquals("3", res.get(0).get(0));
+            },
+            "3"
+        );
+    }
 
-        executeSql("INSERT INTO t1 VALUES ('3', '3')");
-        executeSql("INSERT INTO t2 VALUES ('3', '3', '3')");
+    /**
+     * Test simple join.
+     */
+    @Test
+    public void testSimpleJoin() {
+        createPartitionedTable("t1",
+            pkColumn("k1"),
+            "v2");
 
-        executeSql("INSERT INTO t1 VALUES ('4', '4')");
-        executeSql("INSERT INTO t2 VALUES ('4', '4', '4')");
+        createPartitionedTable("t2",
+            pkColumn("k1"),
+            affinityColumn("ak2"),
+            "v3");
 
-        executeSql("INSERT INTO t1 VALUES ('5', '5')");
-        executeSql("INSERT INTO t2 VALUES ('5', '5', '5')");
+        fillTable("t1", 2, 5);
+        fillTable("t2", 3, 5);
 
         // Key (not alias).
         execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t1.k1 = ?",
@@ -289,14 +326,8 @@ public class JoinPartitionPruningSelfTest extends AbstractPartitionPruningBaseTe
             affinityColumn("ak2"),
             "v3");
 
-        executeSql("INSERT INTO t1 VALUES ('1', '1')");
-        executeSql("INSERT INTO t2 VALUES ('1', '1', '1')");
-
-        executeSql("INSERT INTO t1 VALUES ('2', '2')");
-        executeSql("INSERT INTO t2 VALUES ('2', '2', '2')");
-
-        executeSql("INSERT INTO t1 VALUES ('3', '3')");
-        executeSql("INSERT INTO t2 VALUES ('3', '3', '3')");
+        fillTable("t1", 2, 3);
+        fillTable("t2", 3, 3);
 
         // Left table, should work.
         execute("SELECT * FROM t1, t2 WHERE t1.k1 = ?",
@@ -497,201 +528,6 @@ public class JoinPartitionPruningSelfTest extends AbstractPartitionPruningBaseTe
     }
 
     /**
-     * Test joins with different affinity functions.
-     */
-    @Test
-    public void testJoinWithDifferentAffinityFunctions() {
-        // Partition count.
-        checkAffinityFunctions(
-            cacheConfiguration(256, 1, false, false, false),
-            cacheConfiguration(256, 1, false, false, false),
-            true
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(1024, 1, false, false, false),
-            cacheConfiguration(256, 1, false, false, false),
-            false
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(256, 1, false, false, false),
-            cacheConfiguration(1024, 1, false, false, false),
-            false
-        );
-
-        // Backups.
-        checkAffinityFunctions(
-            cacheConfiguration(256, 1, false, false, false),
-            cacheConfiguration(256, 2, false, false, false),
-            true
-        );
-
-        // Different affinity functions.
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, true, false, false),
-            cacheConfiguration(256, 2, false, false, false),
-            false
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, false, false, false),
-            cacheConfiguration(256, 2, true, false, false),
-            false
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, true, false, false),
-            cacheConfiguration(256, 2, true, false, false),
-            false
-        );
-
-        // Node filters.
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, false, true, false),
-            cacheConfiguration(256, 2, false, false, false),
-            false
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, false, false, false),
-            cacheConfiguration(256, 2, false, true, false),
-            false
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, false, true, false),
-            cacheConfiguration(256, 2, false, true, false),
-            false
-        );
-
-        // With and without persistence.
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, false, false, true),
-            cacheConfiguration(256, 2, false, false, false),
-            false
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, false, false, false),
-            cacheConfiguration(256, 2, false, false, true),
-            false
-        );
-
-        checkAffinityFunctions(
-            cacheConfiguration(256, 2, false, false, true),
-            cacheConfiguration(256, 2, false, false, true),
-            true
-        );
-    }
-
-    /**
-     * @param ccfg1 Cache config 1.
-     * @param ccfg2 Cache config 2.
-     * @param compatible Compatible affinity function flag (false when affinity is incompatible).
-     */
-    @SuppressWarnings("unchecked")
-    private void checkAffinityFunctions(CacheConfiguration ccfg1, CacheConfiguration ccfg2, boolean compatible) {
-        // Destroy old caches.
-        Ignite cli = client();
-
-        cli.destroyCaches(cli.cacheNames());
-
-        // Start new caches.
-        ccfg1.setName("t1");
-        ccfg2.setName("t2");
-
-        QueryEntity entity1 = new QueryEntity(KeyClass1.class, ValueClass.class).setTableName("t1");
-        QueryEntity entity2 = new QueryEntity(KeyClass2.class, ValueClass.class).setTableName("t2");
-
-        ccfg1.setQueryEntities(Collections.singletonList(entity1));
-        ccfg2.setQueryEntities(Collections.singletonList(entity2));
-
-        ccfg1.setKeyConfiguration(new CacheKeyConfiguration(entity1.getKeyType(), "k1"));
-        ccfg2.setKeyConfiguration(new CacheKeyConfiguration(entity2.getKeyType(), "ak2"));
-
-        ccfg1.setSqlSchema(QueryUtils.DFLT_SCHEMA);
-        ccfg2.setSqlSchema(QueryUtils.DFLT_SCHEMA);
-
-        client().createCache(ccfg1);
-        client().createCache(ccfg2);
-
-        // Conduct tests.
-        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t1.k1 = ?",
-            (res) -> assertPartitions(
-                partition("t1", "1")
-            ),
-            "1"
-        );
-
-        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t2.ak2 = ?",
-            (res) -> assertPartitions(
-                partition("t2", "2")
-            ),
-            "2"
-        );
-
-        if (compatible) {
-            execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t1.k1 = ? OR t2.ak2 = ?",
-                (res) -> assertPartitions(
-                    partition("t1", "1"),
-                    partition("t2", "2")
-                ),
-                "1", "2"
-            );
-        }
-        else {
-            execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t1.k1 = ? OR t2.ak2 = ?",
-                (res) -> assertNoPartitions(),
-                "1", "2"
-            );
-        }
-    }
-
-    /**
-     * Create custom cache configuration.
-     *
-     * @param parts Partitions.
-     * @param backups Backups.
-     * @param customAffinity Custom affinity function flag.
-     * @param nodeFilter Whether to set node filter.
-     * @param persistent Whether to enable persistence.
-     * @return Cache configuration.
-     */
-    @SuppressWarnings("IfMayBeConditional")
-    private static CacheConfiguration cacheConfiguration(
-        int parts,
-        int backups,
-        boolean customAffinity,
-        boolean nodeFilter,
-        boolean persistent
-    ) {
-        CacheConfiguration ccfg = new CacheConfiguration();
-
-        ccfg.setCacheMode(CacheMode.PARTITIONED);
-        ccfg.setBackups(backups);
-
-        RendezvousAffinityFunction affFunc;
-
-        if (customAffinity)
-            affFunc = new CustomRendezvousAffinityFunction();
-        else
-            affFunc = new RendezvousAffinityFunction();
-
-        affFunc.setPartitions(parts);
-
-        ccfg.setAffinity(affFunc);
-
-        if (nodeFilter)
-            ccfg.setNodeFilter(new CustomNodeFilter());
-
-        if (persistent)
-            ccfg.setDataRegionName(REGION_DISK);
-
-        return ccfg;
-    }
-
-    /**
      * Test joins with subqueries.
      */
     @Test
@@ -819,55 +655,4 @@ public class JoinPartitionPruningSelfTest extends AbstractPartitionPruningBaseTe
             "1", "2"
         );
     }
-
-    /**
-     * Custom affinity function.
-     */
-    private static class CustomRendezvousAffinityFunction extends RendezvousAffinityFunction {
-        // No-op.
-    }
-
-    /**
-     * Custom node filter.
-     */
-    private static class CustomNodeFilter implements IgnitePredicate<ClusterNode> {
-        /** {@inheritDoc} */
-        @Override public boolean apply(ClusterNode clusterNode) {
-            return true;
-        }
-    }
-
-    /**
-     * Key class 1.
-     */
-    @SuppressWarnings("unused")
-    private static class KeyClass1 {
-        /** Key. */
-        @QuerySqlField
-        private String k1;
-    }
-
-    /**
-     * Key class 2.
-     */
-    @SuppressWarnings("unused")
-    private static class KeyClass2 {
-        /** Key. */
-        @QuerySqlField
-        private String k1;
-
-        /** Affinity key. */
-        @QuerySqlField
-        private String ak2;
-    }
-
-    /**
-     * Value class.
-     */
-    @SuppressWarnings("unused")
-    private static class ValueClass {
-        /** Value. */
-        @QuerySqlField
-        private String v;
-    }
 }
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/JoinQueryEntityPartitionPruningSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/JoinQueryEntityPartitionPruningSelfTest.java
new file mode 100644
index 0000000..60102be
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/JoinQueryEntityPartitionPruningSelfTest.java
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.h2.twostep;
+
+import java.util.Collections;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheKeyConfiguration;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.junit.Test;
+import org.junit.runners.Parameterized;
+
+/**
+ * Tests specific cases of partition pruning for tables created with QueryEntity API.
+ */
+public class JoinQueryEntityPartitionPruningSelfTest extends AbstractPartitionPruningBaseTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        clearIoState();
+    }
+
+    /** */
+    @Parameterized.Parameters(name = "createWithSql = {0}")
+    public static List<?> params() {
+        return F.asList(false);
+    }
+
+    /**
+     * Test custom aliases on PK.
+     */
+    @Test
+    public void testPkAliasJoin() {
+        createPartitionedTable("t1",
+            pkColumn("k1", "ask1"),
+            "v2");
+
+        createPartitionedTable("t2",
+            pkColumn("k1", "ask1"),
+            "v2");
+
+        fillTable("t1", 2, 5);
+        fillTable("t2", 2, 5);
+
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.ask1 = t2.ask1 WHERE t1.ask1 = ?",
+            (res) -> {
+                assertPartitions(
+                    partition("t1", "1")
+                );
+                assertEquals(1, res.size());
+                assertEquals("1", res.get(0).get(0));
+            },
+            "1"
+        );
+
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.ask1 = t2.ask1 WHERE t2.ask1 = ?",
+            (res) -> {
+                assertPartitions(
+                    partition("t1", "3")
+                );
+                assertEquals(1, res.size());
+                assertEquals("3", res.get(0).get(0));
+            },
+            "3"
+        );
+    }
+
+    /**
+     * Test aliases on affinity key.
+     */
+    @Test
+    public void testAffinityAliasJoin() {
+        createPartitionedTable("t1",
+            pkColumn("k1"),
+            "v2");
+
+        createPartitionedTable("t2",
+            pkColumn("k1"),
+            affinityColumn("ak2", "asak2"),
+            "v3");
+
+        fillTable("t1", 2, 5);
+        fillTable("t2", 3, 5);
+
+        // Affinity key.
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.asak2 WHERE t2.asak2 = ?",
+            (res) -> {
+                assertPartitions(
+                    partition("t2", "4")
+                );
+                assertEquals(1, res.size());
+                assertEquals("4", res.get(0).get(0));
+            },
+            "4"
+        );
+    }
+
+    /**
+     * Test joins with different affinity functions.
+     */
+    @Test
+    public void testJoinWithDifferentAffinityFunctions() {
+        // Partition count.
+        checkAffinityFunctions(
+            cacheConfiguration(256, 1, false, false, false),
+            cacheConfiguration(256, 1, false, false, false),
+            true
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(1024, 1, false, false, false),
+            cacheConfiguration(256, 1, false, false, false),
+            false
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(256, 1, false, false, false),
+            cacheConfiguration(1024, 1, false, false, false),
+            false
+        );
+
+        // Backups.
+        checkAffinityFunctions(
+            cacheConfiguration(256, 1, false, false, false),
+            cacheConfiguration(256, 2, false, false, false),
+            true
+        );
+
+        // Different affinity functions.
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, true, false, false),
+            cacheConfiguration(256, 2, false, false, false),
+            false
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, false, false, false),
+            cacheConfiguration(256, 2, true, false, false),
+            false
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, true, false, false),
+            cacheConfiguration(256, 2, true, false, false),
+            false
+        );
+
+        // Node filters.
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, false, true, false),
+            cacheConfiguration(256, 2, false, false, false),
+            false
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, false, false, false),
+            cacheConfiguration(256, 2, false, true, false),
+            false
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, false, true, false),
+            cacheConfiguration(256, 2, false, true, false),
+            false
+        );
+
+        // With and without persistence.
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, false, false, true),
+            cacheConfiguration(256, 2, false, false, false),
+            false
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, false, false, false),
+            cacheConfiguration(256, 2, false, false, true),
+            false
+        );
+
+        checkAffinityFunctions(
+            cacheConfiguration(256, 2, false, false, true),
+            cacheConfiguration(256, 2, false, false, true),
+            true
+        );
+    }
+
+    /**
+     * @param ccfg1 Cache config 1.
+     * @param ccfg2 Cache config 2.
+     * @param compatible Compatible affinity function flag (false when affinity is incompatible).
+     */
+    @SuppressWarnings("unchecked")
+    private void checkAffinityFunctions(CacheConfiguration ccfg1, CacheConfiguration ccfg2, boolean compatible) {
+        // Destroy old caches.
+        Ignite cli = client();
+
+        cli.destroyCaches(cli.cacheNames());
+
+        // Start new caches.
+        ccfg1.setName("t1");
+        ccfg2.setName("t2");
+
+        QueryEntity entity1 = new QueryEntity(KeyClass1.class, ValueClass.class).setTableName("t1");
+        QueryEntity entity2 = new QueryEntity(KeyClass2.class, ValueClass.class).setTableName("t2");
+
+        ccfg1.setQueryEntities(Collections.singletonList(entity1));
+        ccfg2.setQueryEntities(Collections.singletonList(entity2));
+
+        ccfg1.setKeyConfiguration(new CacheKeyConfiguration(entity1.getKeyType(), "k1"));
+        ccfg2.setKeyConfiguration(new CacheKeyConfiguration(entity2.getKeyType(), "ak2"));
+
+        ccfg1.setSqlSchema(QueryUtils.DFLT_SCHEMA);
+        ccfg2.setSqlSchema(QueryUtils.DFLT_SCHEMA);
+
+        client().createCache(ccfg1);
+        client().createCache(ccfg2);
+
+        // Conduct tests.
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t1.k1 = ?",
+            (res) -> assertPartitions(
+                partition("t1", "1")
+            ),
+            "1"
+        );
+
+        execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t2.ak2 = ?",
+            (res) -> assertPartitions(
+                partition("t2", "2")
+            ),
+            "2"
+        );
+
+        if (compatible) {
+            execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t1.k1 = ? OR t2.ak2 = ?",
+                (res) -> assertPartitions(
+                    partition("t1", "1"),
+                    partition("t2", "2")
+                ),
+                "1", "2"
+            );
+        }
+        else {
+            execute("SELECT * FROM t1 INNER JOIN t2 ON t1.k1 = t2.ak2 WHERE t1.k1 = ? OR t2.ak2 = ?",
+                (res) -> assertNoPartitions(),
+                "1", "2"
+            );
+        }
+    }
+
+    /**
+     * Create custom cache configuration.
+     *
+     * @param parts Partitions.
+     * @param backups Backups.
+     * @param customAffinity Custom affinity function flag.
+     * @param nodeFilter Whether to set node filter.
+     * @param persistent Whether to enable persistence.
+     * @return Cache configuration.
+     */
+    @SuppressWarnings("IfMayBeConditional")
+    private static CacheConfiguration cacheConfiguration(
+        int parts,
+        int backups,
+        boolean customAffinity,
+        boolean nodeFilter,
+        boolean persistent
+    ) {
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setCacheMode(CacheMode.PARTITIONED);
+        ccfg.setBackups(backups);
+
+        RendezvousAffinityFunction affFunc;
+
+        if (customAffinity)
+            affFunc = new CustomRendezvousAffinityFunction();
+        else
+            affFunc = new RendezvousAffinityFunction();
+
+        affFunc.setPartitions(parts);
+
+        ccfg.setAffinity(affFunc);
+
+        if (nodeFilter)
+            ccfg.setNodeFilter(new CustomNodeFilter());
+
+        if (persistent)
+            ccfg.setDataRegionName(REGION_DISK);
+
+        return ccfg;
+    }
+
+    /**
+     * Key class 1.
+     */
+    @SuppressWarnings("unused")
+    private static class KeyClass1 {
+        /** Key. */
+        @QuerySqlField
+        private String k1;
+    }
+
+    /**
+     * Key class 2.
+     */
+    @SuppressWarnings("unused")
+    private static class KeyClass2 {
+        /** Key. */
+        @QuerySqlField
+        private String k1;
+
+        /** Affinity key. */
+        @QuerySqlField
+        private String ak2;
+    }
+
+    /**
+     * Value class.
+     */
+    @SuppressWarnings("unused")
+    private static class ValueClass {
+        /** Value. */
+        @QuerySqlField
+        private String v;
+    }
+
+    /**
+     * Custom affinity function.
+     */
+    private static class CustomRendezvousAffinityFunction extends RendezvousAffinityFunction {
+        // No-op.
+    }
+
+    /**
+     * Custom node filter.
+     */
+    private static class CustomNodeFilter implements IgnitePredicate<ClusterNode> {
+        /** {@inheritDoc} */
+        @Override public boolean apply(ClusterNode clusterNode) {
+            return true;
+        }
+    }
+}
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/MvccDmlPartitionPruningSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/MvccDmlPartitionPruningSelfTest.java
index 0deac66..82731ec 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/MvccDmlPartitionPruningSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/MvccDmlPartitionPruningSelfTest.java
@@ -20,12 +20,13 @@ package org.apache.ignite.internal.processors.query.h2.twostep;
 import java.util.List;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.util.typedef.F;
 import org.junit.Test;
+import org.junit.runners.Parameterized;
 
 /**
  * Tests for use partition pruning at the SELECT step of the UPDATE/DELETE statements execution.
  */
-@SuppressWarnings("deprecation")
 public class MvccDmlPartitionPruningSelfTest extends AbstractPartitionPruningBaseTest {
     /** Rows count for test tables. */
     private static final int ROWS = 10;
@@ -33,6 +34,12 @@ public class MvccDmlPartitionPruningSelfTest extends AbstractPartitionPruningBas
     /** Recreate tables before each test statement. */
     private boolean recreateTables;
 
+    /** */
+    @Parameterized.Parameters(name = "createWithSql = {0}")
+    public static List<?> params() {
+        return F.asList(false, true);
+    }
+
     /**
      * Test UPDATE statement.
      */
diff --git a/modules/indexing/src/test/java/org/apache/ignite/sqltests/CheckWarnJoinPartitionedTables.java b/modules/indexing/src/test/java/org/apache/ignite/sqltests/CheckWarnJoinPartitionedTables.java
index eff2f7f..5befdd3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/sqltests/CheckWarnJoinPartitionedTables.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/sqltests/CheckWarnJoinPartitionedTables.java
@@ -18,9 +18,14 @@
 package org.apache.ignite.sqltests;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
 import org.apache.ignite.cache.query.FieldsQueryCursor;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.testframework.ListeningTestLogger;
@@ -303,6 +308,20 @@ public class CheckWarnJoinPartitionedTables extends GridCommonAbstractTest {
     }
 
     /** */
+    @Test
+    public void joinSameTableWithAnnotationAffinityKeyMapped() {
+        QueryEntity qe = new QueryEntity(BookKey.class, BookComment.class)
+            .setTableName("A");
+
+        crd.createCache(new CacheConfiguration<>()
+            .setName("CACHE")
+            .setSqlSchema("PUBLIC")
+            .setQueryEntities(Collections.singletonList(qe)));
+
+        checkSameTableWithComplexPrimaryKeySingleAffKeyWithJoinType();
+    }
+
+    /** */
     private void checkSameTableWithComplexPrimaryKeySingleAffKeyWithJoinType() {
         checkLogListener(false,
             "SELECT a1.* FROM A a1 " + joinType + " A a2 on a1.ID = a2.ID;");
@@ -510,4 +529,27 @@ public class CheckWarnJoinPartitionedTables extends GridCommonAbstractTest {
 
         cursor.getAll();
     }
+
+    /** */
+    private static class BookKey {
+        /** */
+        @QuerySqlField
+        @AffinityKeyMapped
+        private int id;
+
+        /** */
+        @QuerySqlField
+        private String title;
+
+        /** */
+        @QuerySqlField
+        private int price;
+    }
+
+    /** */
+    private static class BookComment {
+        /** */
+        @QuerySqlField
+        private String comment;
+    }
 }
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index c37d315..3ee65f3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
 import org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyTypeRegistryTest;
 import org.apache.ignite.internal.cdc.SqlCdcTest;
 import org.apache.ignite.internal.metric.SystemViewSelfTest;
+import org.apache.ignite.internal.processors.cache.AffinityAliasKeyTest;
 import org.apache.ignite.internal.processors.cache.AffinityKeyNameAndValueFieldNameConflictTest;
 import org.apache.ignite.internal.processors.cache.BigEntryQueryTest;
 import org.apache.ignite.internal.processors.cache.BinaryMetadataConcurrentUpdateWithIndexesTest;
@@ -268,6 +269,7 @@ import org.apache.ignite.internal.processors.query.h2.twostep.BetweenOperationEx
 import org.apache.ignite.internal.processors.query.h2.twostep.DmlSelectPartitionPruningSelfTest;
 import org.apache.ignite.internal.processors.query.h2.twostep.InOperationExtractPartitionSelfTest;
 import org.apache.ignite.internal.processors.query.h2.twostep.JoinPartitionPruningSelfTest;
+import org.apache.ignite.internal.processors.query.h2.twostep.JoinQueryEntityPartitionPruningSelfTest;
 import org.apache.ignite.internal.processors.query.h2.twostep.MvccDmlPartitionPruningSelfTest;
 import org.apache.ignite.internal.processors.query.h2.twostep.SqlDataTypeConversionTest;
 import org.apache.ignite.internal.processors.sql.IgniteCachePartitionedAtomicColumnConstraintsTest;
@@ -302,6 +304,7 @@ import org.junit.runners.Suite;
  */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
+    AffinityAliasKeyTest.class,
     AffinityKeyNameAndValueFieldNameConflictTest.class,
     DmlInsideTransactionTest.class,
     ComplexPrimaryKeyUnwrapSelfTest.class,
@@ -625,6 +628,7 @@ import org.junit.runners.Suite;
     AndOperationExtractPartitionSelfTest.class,
     BetweenOperationExtractPartitionSelfTest.class,
     JoinPartitionPruningSelfTest.class,
+    JoinQueryEntityPartitionPruningSelfTest.class,
     DmlSelectPartitionPruningSelfTest.class,
     MvccDmlPartitionPruningSelfTest.class,