You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2023/08/18 10:43:12 UTC

[ignite-3] branch ignite-20246 updated (f8b82ff84e -> 6ba6e51298)

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

amashenkov pushed a change to branch ignite-20246
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


 discard f8b82ff84e Minor refactoring.
     new 6ba6e51298 Refactoring.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (f8b82ff84e)
            \
             N -- N -- N   refs/heads/ignite-20246 (6ba6e51298)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../sql/engine/exec/DestinationFactory.java        | 117 +++++++++++++++++++++
 .../sql/engine/exec/ExecutionServiceImpl.java      |   4 +-
 .../sql/engine/exec/LogicalRelImplementor.java     |  80 +-------------
 .../internal/sql/engine/externalize/RelJson.java   |   1 -
 .../sql/engine/exec/ExecutionServiceImplTest.java  |   2 +-
 .../internal/sql/engine/framework/TestNode.java    |   2 +-
 6 files changed, 123 insertions(+), 83 deletions(-)
 create mode 100644 modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/DestinationFactory.java


[ignite-3] 01/01: Refactoring.

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-20246
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 6ba6e51298b26a761182d052c2b11d7c3d8d1b5c
Author: amashenkov <an...@gmail.com>
AuthorDate: Fri Aug 18 13:18:15 2023 +0300

    Refactoring.
---
 .../sql/engine/exec/DestinationFactory.java        | 117 +++++++++++++++++++++
 .../sql/engine/exec/ExecutionServiceImpl.java      |   4 +-
 .../sql/engine/exec/LogicalRelImplementor.java     |  12 +--
 .../internal/sql/engine/externalize/RelJson.java   |  24 +++--
 .../sql/engine/trait/DistributionFunction.java     |  73 -------------
 .../sql/engine/trait/DistributionTrait.java        |   8 --
 .../sql/engine/trait/IgniteDistribution.java       |  11 --
 .../sql/engine/util/HashFunctionFactory.java       |   6 +-
 .../sql/engine/util/HashFunctionFactoryImpl.java   |  12 +--
 .../sql/engine/exec/ExecutionServiceImplTest.java  |   2 +-
 .../internal/sql/engine/framework/TestNode.java    |   2 +-
 11 files changed, 151 insertions(+), 120 deletions(-)

diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/DestinationFactory.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/DestinationFactory.java
new file mode 100644
index 0000000000..1d0055e6bf
--- /dev/null
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/DestinationFactory.java
@@ -0,0 +1,117 @@
+/*
+ * 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.sql.engine.exec;
+
+import static org.apache.ignite.internal.util.CollectionUtils.first;
+import static org.apache.ignite.internal.util.CollectionUtils.nullOrEmpty;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import org.apache.calcite.util.ImmutableIntList;
+import org.apache.ignite.internal.sql.engine.metadata.ColocationGroup;
+import org.apache.ignite.internal.sql.engine.metadata.NodeWithTerm;
+import org.apache.ignite.internal.sql.engine.schema.TableDescriptor;
+import org.apache.ignite.internal.sql.engine.trait.AllNodes;
+import org.apache.ignite.internal.sql.engine.trait.Destination;
+import org.apache.ignite.internal.sql.engine.trait.DistributionFunction;
+import org.apache.ignite.internal.sql.engine.trait.DistributionFunction.AffinityDistribution;
+import org.apache.ignite.internal.sql.engine.trait.IgniteDistribution;
+import org.apache.ignite.internal.sql.engine.trait.Partitioned;
+import org.apache.ignite.internal.sql.engine.trait.RandomNode;
+import org.apache.ignite.internal.sql.engine.util.Commons;
+import org.apache.ignite.internal.sql.engine.util.HashFunctionFactory;
+import org.apache.ignite.internal.util.IgniteUtils;
+
+/**
+ * Factory that resolves {@link IgniteDistribution} trait, which represents logical {@link DistributionFunction} function, into its
+ * physical representation - {@link Destination} function.
+ */
+public class DestinationFactory<RowT> {
+    private final HashFunctionFactory<RowT> hashFunctionFactory;
+    private final ResolvedDependencies dependencies;
+
+    /**
+     * Constructor.
+     *
+     * @param hashFunctionFactory Hash-function factory required to resolve hash-based distributions.
+     * @param dependencies Dependencies required to resolve row value dependent distributions.
+     */
+    DestinationFactory(HashFunctionFactory<RowT> hashFunctionFactory, ResolvedDependencies dependencies) {
+        this.hashFunctionFactory = hashFunctionFactory;
+        this.dependencies = dependencies;
+    }
+
+    /**
+     * Creates a destination based on given distribution and nodes mapping.
+     *
+     * @param distribution Distribution function.
+     * @param group Target mapping.
+     * @return Destination function.
+     */
+    Destination<RowT> createDestination(IgniteDistribution distribution, ColocationGroup group) {
+        DistributionFunction function = distribution.function();
+        ImmutableIntList keys = distribution.getKeys();
+
+        switch (function.type()) {
+            case SINGLETON:
+                if (group == null || group.nodeNames() == null || group.nodeNames().size() != 1) {
+                    throw new IllegalStateException();
+                }
+
+                return new AllNodes<>(Collections.singletonList(Objects.requireNonNull(first(group.nodeNames()))));
+            case BROADCAST_DISTRIBUTED:
+                if (group == null || nullOrEmpty(group.nodeNames())) {
+                    throw new IllegalStateException();
+                }
+
+                return new AllNodes<>(group.nodeNames());
+            case RANDOM_DISTRIBUTED:
+                if (group == null || nullOrEmpty(group.nodeNames())) {
+                    throw new IllegalStateException();
+                }
+
+                return new RandomNode<>(group.nodeNames());
+            case HASH_DISTRIBUTED: {
+                if (group == null || nullOrEmpty(group.assignments()) || keys.isEmpty()) {
+                    throw new IllegalStateException();
+                }
+
+                List<List<String>> assignments = Commons.transform(group.assignments(), v -> Commons.transform(v, NodeWithTerm::name));
+
+                if (IgniteUtils.assertionsEnabled()) {
+                    for (List<String> assignment : assignments) {
+                        assert nullOrEmpty(assignment) || assignment.size() == 1;
+                    }
+                }
+
+                if (function.affinity()) {
+                    int tableId = ((AffinityDistribution) function).tableId();
+
+                    TableDescriptor tableDescriptor = dependencies.updatableTable(tableId).descriptor();
+
+                    return new Partitioned<>(assignments, hashFunctionFactory.create(keys.toIntArray(), tableDescriptor));
+                }
+
+                return new Partitioned<>(assignments, hashFunctionFactory.create(keys.toIntArray()));
+            }
+            default:
+                throw new IllegalStateException("Unsupported distribution function.");
+        }
+    }
+}
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java
index 420a5f11be..c07d7de2d1 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java
@@ -161,6 +161,8 @@ public class ExecutionServiceImpl<RowT> implements ExecutionService, TopologyEve
             ExchangeService exchangeSrvc,
             ExecutionDependencyResolver dependencyResolver
     ) {
+        HashFunctionFactoryImpl<RowT> rowHashFunctionFactory = new HashFunctionFactoryImpl<>(handler);
+
         return new ExecutionServiceImpl<>(
                 msgSrvc,
                 topSrvc,
@@ -172,7 +174,7 @@ public class ExecutionServiceImpl<RowT> implements ExecutionService, TopologyEve
                 dependencyResolver,
                 (ctx, deps) -> new LogicalRelImplementor<>(
                         ctx,
-                        new HashFunctionFactoryImpl<>(sqlSchemaManager, handler),
+                        rowHashFunctionFactory,
                         mailboxRegistry,
                         exchangeSrvc,
                         deps)
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/LogicalRelImplementor.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/LogicalRelImplementor.java
index 832ac0d4be..9654236f1b 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/LogicalRelImplementor.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/LogicalRelImplementor.java
@@ -125,7 +125,7 @@ public class LogicalRelImplementor<RowT> implements IgniteRelVisitor<Node<RowT>>
 
     private final ExecutionContext<RowT> ctx;
 
-    private final HashFunctionFactory<RowT> hashFuncFactory;
+    private final DestinationFactory<RowT> destinationFactory;
 
     private final ExchangeService exchangeSvc;
 
@@ -142,7 +142,7 @@ public class LogicalRelImplementor<RowT> implements IgniteRelVisitor<Node<RowT>>
      * @param hashFuncFactory Factory to create a hash function for the row, from which the destination nodes are calculated.
      * @param mailboxRegistry Mailbox registry.
      * @param exchangeSvc Exchange service.
-     * @param resolvedDependencies  Dependencies required to execute this query.
+     * @param resolvedDependencies Dependencies required to execute this query.
      */
     public LogicalRelImplementor(
             ExecutionContext<RowT> ctx,
@@ -150,13 +150,13 @@ public class LogicalRelImplementor<RowT> implements IgniteRelVisitor<Node<RowT>>
             MailboxRegistry mailboxRegistry,
             ExchangeService exchangeSvc,
             ResolvedDependencies resolvedDependencies) {
-        this.hashFuncFactory = hashFuncFactory;
         this.mailboxRegistry = mailboxRegistry;
         this.exchangeSvc = exchangeSvc;
         this.ctx = ctx;
         this.resolvedDependencies = resolvedDependencies;
 
         expressionFactory = ctx.expressionFactory();
+        destinationFactory = new DestinationFactory<>(hashFuncFactory, resolvedDependencies);
     }
 
     /** {@inheritDoc} */
@@ -164,7 +164,7 @@ public class LogicalRelImplementor<RowT> implements IgniteRelVisitor<Node<RowT>>
     public Node<RowT> visit(IgniteSender rel) {
         IgniteDistribution distribution = rel.distribution();
 
-        Destination<RowT> dest = distribution.destination(hashFuncFactory, ctx.target());
+        Destination<RowT> dest = destinationFactory.createDestination(distribution, ctx.target());
 
         // Outbox fragment ID is used as exchange ID as well.
         Outbox<RowT> outbox = new Outbox<>(ctx, exchangeSvc, mailboxRegistry, rel.exchangeId(), rel.targetFragmentId(), dest);
@@ -197,8 +197,8 @@ public class LogicalRelImplementor<RowT> implements IgniteRelVisitor<Node<RowT>>
     public Node<RowT> visit(IgniteTrimExchange rel) {
         assert TraitUtils.distribution(rel).getType() == HASH_DISTRIBUTED;
 
-        IgniteDistribution distr = rel.distribution();
-        Destination<RowT> dest = distr.destination(hashFuncFactory, ctx.group(rel.sourceId()));
+        Destination<RowT> dest = destinationFactory.createDestination(rel.distribution(), ctx.target());
+
         String localNodeName = ctx.localNode().name();
 
         FilterNode<RowT> node = new FilterNode<>(ctx, r -> Objects.equals(localNodeName, first(dest.targets(r))));
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/externalize/RelJson.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/externalize/RelJson.java
index b494492bdb..f66116c2d2 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/externalize/RelJson.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/externalize/RelJson.java
@@ -101,7 +101,6 @@ import org.apache.calcite.sql.type.SqlTypeFamily;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.sql.validate.SqlNameMatchers;
 import org.apache.calcite.util.ImmutableBitSet;
-import org.apache.calcite.util.ImmutableIntList;
 import org.apache.calcite.util.Util;
 import org.apache.ignite.internal.sql.engine.prepare.bounds.ExactBounds;
 import org.apache.ignite.internal.sql.engine.prepare.bounds.MultiBounds;
@@ -532,13 +531,14 @@ class RelJson {
                     keys.add(toJson(key));
                 }
 
+                map.put("func", distribution.function().name());
                 map.put("keys", keys);
 
                 DistributionFunction function = distribution.function();
 
                 if (function.affinity()) {
                     map.put("zoneId", ((AffinityDistribution) function).zoneId());
-                    map.put("tableId", Integer.toString(((AffinityDistribution) function).tableId()));
+                    map.put("tableId", ((AffinityDistribution) function).tableId());
                 }
 
                 return map;
@@ -671,16 +671,22 @@ class RelJson {
         }
 
         Map<String, Object> map = (Map<String, Object>) distribution;
-        String tableIdStr = (String) map.get("tableId");
+        String functionName = (String) map.get("func");
 
-        if (tableIdStr != null) {
-            int tableId = Integer.parseInt(tableIdStr);
-            Object zoneId = map.get("zoneId");
+        List<Integer> keys = (List<Integer>) map.get("keys");
 
-            return IgniteDistributions.affinity((List<Integer>) map.get("keys"), tableId, zoneId);
-        }
+        switch (functionName) {
+            case "hash":
+                return IgniteDistributions.hash(keys, DistributionFunction.hash());
+            default: {
+                assert functionName.startsWith("affinity");
+
+                int tableId = (int) map.get("tableId");
+                Object zoneId = map.get("zoneId");
 
-        return IgniteDistributions.hash(ImmutableIntList.copyOf((List<Integer>) map.get("keys")), DistributionFunction.hash());
+                return IgniteDistributions.affinity(keys, tableId, zoneId);
+            }
+        }
     }
 
     RelDataType toType(RelDataTypeFactory typeFactory, Object o) {
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionFunction.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionFunction.java
index ed5e8584a2..598bc880e0 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionFunction.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionFunction.java
@@ -17,20 +17,9 @@
 
 package org.apache.ignite.internal.sql.engine.trait;
 
-import static org.apache.ignite.internal.util.CollectionUtils.first;
-import static org.apache.ignite.internal.util.CollectionUtils.nullOrEmpty;
-
-import java.util.Collections;
-import java.util.List;
 import java.util.Objects;
 import org.apache.calcite.rel.RelDistribution;
 import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.util.ImmutableIntList;
-import org.apache.ignite.internal.sql.engine.metadata.ColocationGroup;
-import org.apache.ignite.internal.sql.engine.metadata.NodeWithTerm;
-import org.apache.ignite.internal.sql.engine.util.Commons;
-import org.apache.ignite.internal.sql.engine.util.HashFunctionFactory;
-import org.apache.ignite.internal.util.IgniteUtils;
 
 /**
  * Distribution function.
@@ -66,16 +55,6 @@ public abstract class DistributionFunction {
         return new AffinityDistribution(tableId, zoneId);
     }
 
-    /**
-     * Creates a destination based on this function algorithm, given nodes mapping and given distribution keys.
-     *
-     * @param hashFuncFactory Factory to create a hash function for the row, from which the destination nodes are calculated.
-     * @param group           Target mapping.
-     * @param keys            Distribution keys.
-     * @return Destination function.
-     */
-    abstract <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup group, ImmutableIntList keys);
-
     /**
      * Get function name. This name used for equality checking and in {@link RelNode#getDigest()}.
      */
@@ -147,11 +126,6 @@ public abstract class DistributionFunction {
             return RelDistribution.Type.ANY;
         }
 
-        /** {@inheritDoc} */
-        @Override
-        public <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup m, ImmutableIntList k) {
-            throw new IllegalStateException();
-        }
     }
 
     private static final class BroadcastDistribution extends DistributionFunction {
@@ -163,13 +137,6 @@ public abstract class DistributionFunction {
             return RelDistribution.Type.BROADCAST_DISTRIBUTED;
         }
 
-        /** {@inheritDoc} */
-        @Override
-        public <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup m, ImmutableIntList k) {
-            assert m != null && !nullOrEmpty(m.nodeNames());
-
-            return new AllNodes<>(m.nodeNames());
-        }
     }
 
     private static final class RandomDistribution extends DistributionFunction {
@@ -181,13 +148,6 @@ public abstract class DistributionFunction {
             return RelDistribution.Type.RANDOM_DISTRIBUTED;
         }
 
-        /** {@inheritDoc} */
-        @Override
-        public <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup m, ImmutableIntList k) {
-            assert m != null && !nullOrEmpty(m.nodeNames());
-
-            return new RandomNode<>(m.nodeNames());
-        }
     }
 
     private static final class SingletonDistribution extends DistributionFunction {
@@ -199,15 +159,6 @@ public abstract class DistributionFunction {
             return RelDistribution.Type.SINGLETON;
         }
 
-        /** {@inheritDoc} */
-        @Override
-        public <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup m, ImmutableIntList k) {
-            if (m == null || m.nodeNames() == null || m.nodeNames().size() != 1) {
-                throw new IllegalStateException();
-            }
-
-            return new AllNodes<>(Collections.singletonList(Objects.requireNonNull(first(m.nodeNames()))));
-        }
     }
 
     private static class HashDistribution extends DistributionFunction {
@@ -219,25 +170,6 @@ public abstract class DistributionFunction {
             return RelDistribution.Type.HASH_DISTRIBUTED;
         }
 
-        /** {@inheritDoc} */
-        @Override
-        public <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup m, ImmutableIntList k) {
-            assert m != null && !nullOrEmpty(m.assignments()) && !k.isEmpty();
-
-            List<List<String>> assignments = Commons.transform(m.assignments(), v -> Commons.transform(v, NodeWithTerm::name));
-
-            if (IgniteUtils.assertionsEnabled()) {
-                for (List<String> assignment : assignments) {
-                    assert nullOrEmpty(assignment) || assignment.size() == 1;
-                }
-            }
-
-            return destination(assignments, hashFuncFactory, k.toIntArray());
-        }
-
-        protected <RowT> Destination<RowT> destination(List<List<String>> assignments, HashFunctionFactory<RowT> funcFactory, int[] keys) {
-            return new Partitioned<>(assignments, funcFactory.create(keys));
-        }
     }
 
     /**
@@ -273,11 +205,6 @@ public abstract class DistributionFunction {
             return zoneId;
         }
 
-        @Override
-        protected <RowT> Destination<RowT> destination(List<List<String>> assignments, HashFunctionFactory<RowT> funcFactory, int[] keys) {
-            return new Partitioned<>(assignments, funcFactory.create(keys, tableId));
-        }
-
         /** {@inheritDoc} */
         @Override
         protected String name0() {
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionTrait.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionTrait.java
index f73f16c70e..12bd13d77c 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionTrait.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/DistributionTrait.java
@@ -33,8 +33,6 @@ import org.apache.calcite.plan.RelTrait;
 import org.apache.calcite.util.ImmutableIntList;
 import org.apache.calcite.util.mapping.Mapping;
 import org.apache.calcite.util.mapping.Mappings;
-import org.apache.ignite.internal.sql.engine.metadata.ColocationGroup;
-import org.apache.ignite.internal.sql.engine.util.HashFunctionFactory;
 
 /**
  * Description of the physical distribution of a relational expression.
@@ -103,12 +101,6 @@ public final class DistributionTrait implements IgniteDistribution {
         return function;
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup target) {
-        return function.destination(hashFuncFactory, target, keys);
-    }
-
     /** {@inheritDoc} */
     @Override
     public ImmutableIntList getKeys() {
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/IgniteDistribution.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/IgniteDistribution.java
index 99cfd8329a..f38be86972 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/IgniteDistribution.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/IgniteDistribution.java
@@ -20,8 +20,6 @@ package org.apache.ignite.internal.sql.engine.trait;
 import org.apache.calcite.rel.RelDistribution;
 import org.apache.calcite.util.ImmutableIntList;
 import org.apache.calcite.util.mapping.Mappings;
-import org.apache.ignite.internal.sql.engine.metadata.ColocationGroup;
-import org.apache.ignite.internal.sql.engine.util.HashFunctionFactory;
 
 /**
  * Ignite distribution trait.
@@ -32,15 +30,6 @@ public interface IgniteDistribution extends RelDistribution {
      */
     DistributionFunction function();
 
-    /**
-     * Creates a destination based on this function algorithm, given nodes mapping and distribution keys.
-     *
-     * @param hashFuncFactory Factory to create a hash function for the row, from which the destination nodes are calculated.
-     * @param targetGroup     Target mapping.
-     * @return Destination function.
-     */
-    <RowT> Destination<RowT> destination(HashFunctionFactory<RowT> hashFuncFactory, ColocationGroup targetGroup);
-
     /** {@inheritDoc} */
     @Override
     ImmutableIntList getKeys();
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactory.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactory.java
index 98db93e282..c755a880cc 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactory.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactory.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.sql.engine.util;
 
+import org.apache.ignite.internal.sql.engine.schema.TableDescriptor;
+
 /**
  * Factory for creating a function to calculate the hash of the specified fields of the row.
  */
@@ -49,8 +51,8 @@ public interface HashFunctionFactory<T> {
      * Creates a hash function to compute a composite hash of a row, given the types and values of the fields.
      *
      * @param fields Field ordinals of the row from which the hash is to be calculated.
-     * @param tableId Table ID.
+     * @param tableDescriptor Table descriptor.
      * @return Function to compute a composite hash of a row, given the types and values of the fields.
      */
-    RowHashFunction<T> create(int[] fields, int tableId);
+    RowHashFunction<T> create(int[] fields, TableDescriptor tableDescriptor);
 }
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactoryImpl.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactoryImpl.java
index 4ad5484257..68af4ef9b5 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactoryImpl.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/HashFunctionFactoryImpl.java
@@ -26,7 +26,6 @@ import org.apache.ignite.internal.schema.NativeType;
 import org.apache.ignite.internal.schema.NativeTypeSpec;
 import org.apache.ignite.internal.sql.engine.exec.RowHandler;
 import org.apache.ignite.internal.sql.engine.schema.ColumnDescriptor;
-import org.apache.ignite.internal.sql.engine.schema.SqlSchemaManager;
 import org.apache.ignite.internal.sql.engine.schema.TableDescriptor;
 import org.apache.ignite.internal.util.ColocationUtils;
 import org.apache.ignite.internal.util.HashCalculator;
@@ -35,26 +34,23 @@ import org.apache.ignite.internal.util.HashCalculator;
  * Factory for creating a function to calculate the hash of the specified fields of a row.
  */
 public class HashFunctionFactoryImpl<T> implements HashFunctionFactory<T> {
-    private final SqlSchemaManager sqlSchemaManager;
     private final RowHandler<T> rowHandler;
 
-    public HashFunctionFactoryImpl(SqlSchemaManager sqlSchemaManager, RowHandler<T> rowHandler) {
-        this.sqlSchemaManager = sqlSchemaManager;
+    public HashFunctionFactoryImpl(RowHandler<T> rowHandler) {
         this.rowHandler = rowHandler;
     }
 
     /** {@inheritDoc} */
     @Override
-    public RowHashFunction<T> create(int[] fields, int tableId) {
+    public RowHashFunction<T> create(int[] fields, TableDescriptor tableDescriptor) {
         int fieldCnt = fields.length;
         NativeType[] fieldTypes = new NativeType[fieldCnt];
-        TableDescriptor tblDesc = sqlSchemaManager.tableById(tableId).descriptor();
-        ImmutableIntList colocationColumns = tblDesc.distribution().getKeys();
+        ImmutableIntList colocationColumns = tableDescriptor.distribution().getKeys();
 
         assert colocationColumns.size() == fieldCnt : "fieldsCount=" + fieldCnt + ", colocationColumns=" + colocationColumns;
 
         for (int i = 0; i < fieldCnt; i++) {
-            ColumnDescriptor colDesc = tblDesc.columnDescriptor(colocationColumns.getInt(i));
+            ColumnDescriptor colDesc = tableDescriptor.columnDescriptor(colocationColumns.getInt(i));
 
             fieldTypes[i] = colDesc.physicalType();
         }
diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImplTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImplTest.java
index 4a5a0a6a1c..8bbdfbfac4 100644
--- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImplTest.java
+++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImplTest.java
@@ -787,7 +787,7 @@ public class ExecutionServiceImplTest {
                     MailboxRegistry mailboxRegistry,
                     ExchangeService exchangeService,
                     ResolvedDependencies deps) {
-                HashFunctionFactory<Object[]> funcFactory = new HashFunctionFactoryImpl<>(mock(SqlSchemaManager.class), ctx.rowHandler());
+                HashFunctionFactory<Object[]> funcFactory = new HashFunctionFactoryImpl<>(ctx.rowHandler());
 
                 return new LogicalRelImplementor<>(ctx, funcFactory, mailboxRegistry, exchangeService, deps) {
                     @Override
diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestNode.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestNode.java
index 3eaa2abc2d..c55f3ee79b 100644
--- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestNode.java
+++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/TestNode.java
@@ -134,7 +134,7 @@ public class TestNode implements LifecycleAware {
                 dependencyResolver,
                 (ctx, deps) -> new LogicalRelImplementor<Object[]>(
                         ctx,
-                        new HashFunctionFactoryImpl<>(schemaManager, rowHandler),
+                        new HashFunctionFactoryImpl<>(rowHandler),
                         mailboxRegistry,
                         exchangeService,
                         deps