[ignite-3] branch main updated: IGNITE-18111 .NET: LINQ: Add KeyValueView support (#1373)

2022-11-24 Thread ptupitsyn
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 2a74a95182 IGNITE-18111 .NET: LINQ: Add KeyValueView support (#1373)
2a74a95182 is described below

commit 2a74a951826b1496c14dab22fbe31691dc1b36e6
Author: Pavel Tupitsyn 
AuthorDate: Thu Nov 24 12:01:49 2022 +0300

IGNITE-18111 .NET: LINQ: Add KeyValueView support (#1373)

* Implement `IKeyValueView.AsQueryable`.
* Disallow primitive types in LINQ (e.g. `IKeyValueView`): not 
possible to determine column names.
* Fix single column queries - replace `SqlTypes` from 2.x with 
`SqlColumnTypeExtensions` to match new SQL engine.
---
 .../dotnet/Apache.Ignite.Tests/.editorconfig   |   3 +-
 .../Linq/LinqSqlGenerationTests.KvView.cs  | 114 +++
 .../Linq/LinqSqlGenerationTests.cs |  64 -
 .../Apache.Ignite.Tests/Linq/LinqTests.KvView.cs   | 157 +
 .../Sql/SqlColumnTypeExtensionsTests.cs|  50 +++
 .../Table/Serialization/ReflectionUtilsTests.cs|   2 +-
 .../dotnet/Apache.Ignite/Internal/Linq/DEVNOTES.md |   1 +
 .../Internal/Linq/IgniteQueryExecutor.cs   |  49 +--
 .../Internal/Linq/IgniteQueryExpressionVisitor.cs  | 129 -
 .../dotnet/Apache.Ignite/Internal/Linq/SqlTypes.cs |  72 --
 .../Internal/Sql/SqlColumnTypeExtensions.cs|  99 +
 .../Apache.Ignite/Internal/Table/KeyValueView.cs   |   7 +-
 .../Apache.Ignite/Internal/Table/RecordView.cs |  18 +++
 .../Table/Serialization/ReflectionUtils.cs |  27 +++-
 14 files changed, 663 insertions(+), 129 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/.editorconfig 
b/modules/platforms/dotnet/Apache.Ignite.Tests/.editorconfig
index 54d4f8a3c2..5cfad90769 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/.editorconfig
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/.editorconfig
@@ -39,6 +39,5 @@ dotnet_diagnostic.CA2201.severity = none # Do not raise 
reserved exception types
 dotnet_diagnostic.CA1508.severity = none # Avoid dead conditional code
 dotnet_diagnostic.CA1305.severity = none # Specify IFormatProvider
 dotnet_diagnostic.CA1819.severity = none # Properties should not return arrays
-
-
+dotnet_diagnostic.CA1812.severity = none # Avoid uninstantiated internal 
classes
 
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.KvView.cs
 
b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.KvView.cs
new file mode 100644
index 00..4f5f800623
--- /dev/null
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.KvView.cs
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Tests.Linq;
+
+using System;
+using System.Linq;
+using Ignite.Sql;
+using Ignite.Table;
+using NUnit.Framework;
+using Table;
+
+/// 
+/// Tests LINQ to SQL conversion for .
+/// 
+/// Uses  to get the actual SQL sent from the client.
+/// 
+public partial class LinqSqlGenerationTests
+{
+[Test]
+public void TestSelectPrimitiveKeyColumnKv() =>
+AssertSqlKv("select _T0.VAL from PUBLIC.tbl1 as _T0", q => q.Select(x 
=> x.Value.Val).ToList());
+
+[Test]
+public void TestSelectPocoValColumnKv() =>
+AssertSqlKv("select _T0.KEY, _T0.VAL from PUBLIC.tbl1 as _T0", q => 
q.Select(x => x.Value).ToList());
+
+[Test]
+public void TestSelectTwoColumnsKv() =>
+AssertSqlKv(
+"select (_T0.KEY + ?), _T0.VAL from PUBLIC.tbl1 as _T0",
+q => q.Select(x => new { Key = x.Key.Key + 1, x.Value.Val 
}).ToList());
+
+[Test]
+public void TestSelectAllColumnsCustomNamesKv() =>
+AssertSql(
+"select _T0.\"KEY\", _T0.\"VAL\" from PUBLIC.tbl1 as _T0",
+tbl => tbl.GetKeyValueView().AsQueryable().ToList());
+
+[Test]
+public void TestSelectSameColumnFromPairKeyAndValKv()
+{
+// We avoid selecting same column twice if it is included in both Key 
and Value parts,
+

[ignite-3] branch main updated: IGNITE-18248 Introduce LeaderOrTxState class instead of IgniteBiTuple (#1374)

2022-11-24 Thread ibessonov
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 5269927cca IGNITE-18248 Introduce LeaderOrTxState class instead of 
IgniteBiTuple (#1374)
5269927cca is described below

commit 5269927cca002b635b3768570aa9e2f1c7e06064
Author: Alexander Polovtcev 
AuthorDate: Thu Nov 24 13:18:06 2022 +0300

IGNITE-18248 Introduce LeaderOrTxState class instead of IgniteBiTuple 
(#1374)
---
 .../distributed/replicator/LeaderOrTxState.java| 57 ++
 .../replicator/PartitionReplicaListener.java   | 21 
 .../distributed/replicator/PlacementDriver.java|  9 ++--
 .../replication/PartitionReplicaListenerTest.java  | 30 ++--
 4 files changed, 85 insertions(+), 32 deletions(-)

diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/LeaderOrTxState.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/LeaderOrTxState.java
new file mode 100644
index 00..d36859d084
--- /dev/null
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/LeaderOrTxState.java
@@ -0,0 +1,57 @@
+/*
+ * 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.table.distributed.replicator;
+
+import java.io.Serializable;
+import org.apache.ignite.internal.tx.TxMeta;
+import org.apache.ignite.internal.tx.message.TxStateReplicaRequest;
+import org.apache.ignite.network.ClusterNode;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Response for the {@link TxStateReplicaRequest}. Can contain either the 
Partition Group leader, which should be
+ * queried for the TX Meta, or the TX Meta itself.
+ */
+public class LeaderOrTxState implements Serializable {
+private static final long serialVersionUID = -391755828355117L;
+
+@Nullable
+private final ClusterNode leader;
+
+@Nullable
+private final TxMeta txMeta;
+
+/**
+ * Creates a response.
+ *
+ * @param leader Leader node.
+ * @param txMeta TX meta.
+ */
+public LeaderOrTxState(@Nullable ClusterNode leader, @Nullable TxMeta 
txMeta) {
+this.leader = leader;
+this.txMeta = txMeta;
+}
+
+public @Nullable ClusterNode leader() {
+return leader;
+}
+
+public @Nullable TxMeta txMeta() {
+return txMeta;
+}
+}
diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
index b7bb6b3b91..dbc0c2585f 100644
--- 
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
@@ -131,7 +131,7 @@ public class PartitionReplicaListener implements 
ReplicaListener {
 private final int partId;
 
 /** Primary key index. */
-public final Lazy pkIndexStorage;
+private final Lazy pkIndexStorage;
 
 /** Secondary indices. */
 private final Supplier> 
secondaryIndexStorages;
@@ -303,19 +303,16 @@ public class PartitionReplicaListener implements 
ReplicaListener {
 private CompletableFuture 
processTxStateReplicaRequest(TxStateReplicaRequest request) {
 return raftClient.refreshAndGetLeaderWithTerm()
 .thenCompose(replicaAndTerm -> {
-String leaderId = 
replicaAndTerm.leader().consistentId();
+Peer leader = replicaAndTerm.leader();
 
-if 
(topologyService.localMember().name().equals(leaderId)) {
+if (isLocalPeerChecker.apply(leader)) {
+CompletableFuture txStateFut = 
getTxStateConcurrently(request);
 
-CompletableFuture txStateFut = 
getTxStateConcurrently(request);
-
-return txStateFut.thenApply(txMeta -

[ignite-3] branch main updated: IGNITE-18056 Sql. Make RangeConditions accordant to index row type (#1329)

2022-11-24 Thread amashenkov
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 33b578bcad IGNITE-18056 Sql. Make RangeConditions accordant to index 
row type (#1329)
33b578bcad is described below

commit 33b578bcad191ace4f2274dbb252e1f8ef6c78c8
Author: Andrew V. Mashenkov 
AuthorDate: Thu Nov 24 14:03:43 2022 +0300

IGNITE-18056 Sql. Make RangeConditions accordant to index row type (#1329)
---
 .../apache/ignite/internal/index/HashIndex.java|  11 +-
 .../org/apache/ignite/internal/index/Index.java|  13 +-
 .../apache/ignite/internal/index/SortedIndex.java  |  12 +-
 .../ignite/internal/index/SortedIndexImpl.java |  20 ++-
 .../internal/sql/engine/exec/ExecutionContext.java |  13 --
 .../sql/engine/exec/LogicalRelImplementor.java |  20 ++-
 .../internal/sql/engine/exec/RowConverter.java |  59 +++
 .../sql/engine/exec/exp/ExpressionFactory.java |   7 +-
 .../sql/engine/exec/exp/ExpressionFactoryImpl.java |  48 +++---
 .../internal/sql/engine/exec/exp/RexImpTable.java  |   9 ++
 .../sql/engine/exec/rel/IndexScanNode.java |  21 +--
 .../engine/rel/logical/IgniteLogicalIndexScan.java |  39 +++--
 .../FilterSpoolMergeToSortedIndexSpoolRule.java|   5 +-
 .../internal/sql/engine/schema/IgniteIndex.java|  30 
 .../sql/engine/schema/TableDescriptor.java |   3 +-
 .../sql/engine/schema/TableDescriptorImpl.java |   3 +-
 .../internal/sql/engine/trait/TraitUtils.java  |  23 ++-
 .../internal/sql/engine/util/IgniteMethod.java |   2 -
 .../ignite/internal/sql/engine/util/RexUtils.java  |  45 +++---
 .../exec/rel/IndexScanNodeExecutionTest.java   | 169 -
 .../exec/rel/SortedIndexSpoolExecutionTest.java|   3 +-
 .../CorrelatedNestedLoopJoinPlannerTest.java   |   9 +-
 .../planner/ProjectFilterScanMergePlannerTest.java |  58 ++-
 .../planner/SortedIndexSpoolPlannerTest.java   |  26 ++--
 .../replicator/PartitionReplicaListener.java   |  59 +++
 25 files changed, 431 insertions(+), 276 deletions(-)

diff --git 
a/modules/index/src/main/java/org/apache/ignite/internal/index/HashIndex.java 
b/modules/index/src/main/java/org/apache/ignite/internal/index/HashIndex.java
index ae03fdd3c5..069b1f7b1b 100644
--- 
a/modules/index/src/main/java/org/apache/ignite/internal/index/HashIndex.java
+++ 
b/modules/index/src/main/java/org/apache/ignite/internal/index/HashIndex.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.table.InternalTable;
 import org.apache.ignite.internal.table.TableImpl;
 import org.apache.ignite.internal.tx.InternalTransaction;
 import org.apache.ignite.network.ClusterNode;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * An object that represents a hash index.
@@ -76,13 +77,19 @@ public class HashIndex implements Index {
 
 /** {@inheritDoc} */
 @Override
-public Publisher lookup(int partId, InternalTransaction tx, 
BinaryTuple key, BitSet columns) {
+public Publisher lookup(int partId, @Nullable 
InternalTransaction tx, BinaryTuple key, @Nullable BitSet columns) {
 return table.lookup(partId, tx, id, key, columns);
 }
 
 /** {@inheritDoc} */
 @Override
-public Publisher lookup(int partId, HybridTimestamp timestamp, 
ClusterNode recipientNode, BinaryTuple key, BitSet columns) {
+public Publisher lookup(
+int partId,
+HybridTimestamp timestamp,
+ClusterNode recipientNode,
+BinaryTuple key,
+@Nullable BitSet columns
+) {
 return table.lookup(partId, timestamp, recipientNode, id, key, 
columns);
 }
 }
diff --git 
a/modules/index/src/main/java/org/apache/ignite/internal/index/Index.java 
b/modules/index/src/main/java/org/apache/ignite/internal/index/Index.java
index 68eb57d93d..896ee3ab09 100644
--- a/modules/index/src/main/java/org/apache/ignite/internal/index/Index.java
+++ b/modules/index/src/main/java/org/apache/ignite/internal/index/Index.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.schema.BinaryRow;
 import org.apache.ignite.internal.schema.BinaryTuple;
 import org.apache.ignite.internal.tx.InternalTransaction;
 import org.apache.ignite.network.ClusterNode;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * An object describing an abstract index.
@@ -41,7 +42,7 @@ public interface Index {
 /** Returns table id index belong to. */
 UUID tableId();
 
-/** Returns index dewscriptor. */
+/** Returns index descriptor. */
 DescriptorT descriptor();
 
 /**
@@ -53,7 +54,7 @@ public interface Index {
  * @param columns Columns to include.
  * @return A cursor from resulting rows.
  */
-Publisher lookup(int partId, InternalTransaction tx, 
BinaryTuple key, BitSet columns);
+Publisher lookup(int partId, @Nullable InternalTransaction tx, 
BinaryTu

[ignite-3] branch main updated: IGNITE-18240 Store logical topology as a single KV entry instead of a number of entries (#1371)

2022-11-24 Thread sdanilov
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 2405febe72 IGNITE-18240 Store logical topology as a single KV entry 
instead of a number of entries (#1371)
2405febe72 is described below

commit 2405febe72fd295a1044bcdb6787b7f6a8389d7a
Author: Roman Puchkovskiy 
AuthorDate: Thu Nov 24 17:36:06 2022 +0400

IGNITE-18240 Store logical topology as a single KV entry instead of a 
number of entries (#1371)
---
 .../management/raft/RaftStorageManager.java| 128 ++---
 .../raft/commands/NodesLeaveCommand.java   |   2 +-
 .../AbstractClusterStateStorageManagerTest.java|  39 +++
 3 files changed, 126 insertions(+), 43 deletions(-)

diff --git 
a/modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/RaftStorageManager.java
 
b/modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/RaftStorageManager.java
index f3c94cbfea..77c79da236 100644
--- 
a/modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/RaftStorageManager.java
+++ 
b/modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/RaftStorageManager.java
@@ -18,20 +18,25 @@
 package org.apache.ignite.internal.cluster.management.raft;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.Collections.emptySet;
+import static java.util.function.Function.identity;
 import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
 import static org.apache.ignite.internal.util.ArrayUtils.BYTE_EMPTY_ARRAY;
 import static org.apache.ignite.internal.util.ByteUtils.fromBytes;
 import static org.apache.ignite.internal.util.ByteUtils.toBytes;
 
+import java.io.Serializable;
 import java.nio.ByteBuffer;
 import java.nio.file.Path;
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import org.apache.ignite.internal.cluster.management.ClusterState;
+import org.apache.ignite.internal.tostring.IgniteToStringInclude;
+import org.apache.ignite.internal.tostring.S;
 import org.apache.ignite.internal.util.Cursor;
-import org.apache.ignite.lang.IgniteInternalException;
 import org.apache.ignite.network.ClusterNode;
 import org.jetbrains.annotations.Nullable;
 
@@ -42,16 +47,20 @@ class RaftStorageManager {
 /** Storage key for the CMG state. */
 private static final byte[] CMG_STATE_KEY = "cmg_state".getBytes(UTF_8);
 
-/** Prefix for the keys for logical topology nodes. */
-private static final byte[] LOGICAL_TOPOLOGY_PREFIX = 
"logical_".getBytes(UTF_8);
+/** Storage key for the logical topology. */
+private static final byte[] LOGICAL_TOPOLOGY_KEY = 
"logical".getBytes(UTF_8);
 
 /** Prefix for validation tokens. */
 private static final byte[] VALIDATED_NODE_PREFIX = 
"validation_".getBytes(UTF_8);
 
 private final ClusterStateStorage storage;
 
+private volatile LogicalTopology currentLogicalTopology;
+
 RaftStorageManager(ClusterStateStorage storage) {
 this.storage = storage;
+
+currentLogicalTopology = readLogicalTopology();
 }
 
 /**
@@ -79,11 +88,13 @@ class RaftStorageManager {
  * Retrieves the current logical topology.
  */
 Collection getLogicalTopology() {
-try (Cursor cursor = 
storage.getWithPrefix(LOGICAL_TOPOLOGY_PREFIX, (k, v) -> fromBytes(v))) {
-return cursor.stream().collect(toList());
-} catch (Exception e) {
-throw new IgniteInternalException("Unable to get data from 
storage", e);
-}
+return currentLogicalTopology.nodes;
+}
+
+private LogicalTopology readLogicalTopology() {
+byte[] bytes = storage.get(LOGICAL_TOPOLOGY_KEY);
+
+return bytes == null ? LogicalTopology.INITIAL : fromBytes(bytes);
 }
 
 /**
@@ -92,16 +103,17 @@ class RaftStorageManager {
  * @param node Node to save.
  */
 void putLogicalTopologyNode(ClusterNode node) {
-byte[] nodeNameBytes = node.name().getBytes(UTF_8);
-
-byte[] nodeIdBytes = node.id().getBytes(UTF_8);
+replaceLogicalTopologyWith(currentLogicalTopology.addNode(node));
+}
 
-byte[] key = logicalTopologyKey(nodeNameBytes, nodeIdBytes);
+private void replaceLogicalTopologyWith(LogicalTopology newTopology) {
+if (newTopology == currentLogicalTopology) {
+return;
+}
 
-// Replace all nodes with the same consistent ID.
-byte[] prefix = Arrays.copyOf(key, key.length - nodeIdBytes.length);
+storage.put(LOGICAL_TOPOLOGY_KEY, toBytes(newTopology));
 
-storage.replaceAll(prefix, key, toBytes(node));
+currentL

[ignite-3] branch ignite-18171 updated: Wip.

2022-11-24 Thread amashenkov
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/ignite-18171 by this push:
 new 699830e80e Wip.
699830e80e is described below

commit 699830e80e6f4a9ade3ba9985ada6c5363d53cda
Author: amashenkov 
AuthorDate: Thu Nov 24 17:04:02 2022 +0300

Wip.
---
 .../ignite/internal/ItNodeStartStopTest.java   | 378 +
 1 file changed, 238 insertions(+), 140 deletions(-)

diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
index 9bfdd00d12..a34e3d6523 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
@@ -17,32 +17,38 @@
 
 package org.apache.ignite.internal;
 
-import static org.junit.jupiter.api.Assertions.fail;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.lang.reflect.Method;
 import java.nio.file.Path;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.CompletableFuture;
 import java.util.function.BiPredicate;
-import java.util.function.Consumer;
 import java.util.function.Predicate;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
 import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
 import org.apache.ignite.internal.testframework.WorkDirectory;
 import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
 import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DynamicContainer;
+import org.junit.jupiter.api.DynamicNode;
 import org.junit.jupiter.api.DynamicTest;
 import org.junit.jupiter.api.TestFactory;
 import org.junit.jupiter.api.TestInfo;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.api.function.Executable;
 
 @ExtendWith(WorkDirectoryExtension.class)
 public class ItNodeStartStopTest extends BaseIgniteAbstractTest {
@@ -50,205 +56,297 @@ public class ItNodeStartStopTest extends 
BaseIgniteAbstractTest {
 @WorkDirectory
 private static Path WORK_DIR;
 
+private static final String connectionAddr = "\"localhost:3344\", 
\"localhost:3345\", \"localhost:3346\"";
+
 /** Nodes configurations. */
-private final Map nodesCfg = Map.of(
-"C", "",
-"M", "",
-"D", "",
-"D2", ""
-); // Node name -> config.
+private static final Map nodesCfg = Map.of(
+"C", "{\n"
++ "  \"network\": {\n"
++ "\"port\":3344,\n"
++ "\"nodeFinder\":{\n"
++ "  \"netClusterNodes\": [ " + connectionAddr + " ]\n"
++ "}\n"
++ "  }\n"
++ "}",
+"M", "{\n"
++ "  \"network\": {\n"
++ "\"port\":3345,\n"
++ "\"nodeFinder\":{\n"
++ "  \"netClusterNodes\": [ " + connectionAddr + " ]\n"
++ "}\n"
++ "  }\n"
++ "}",
+"D", "{\n"
++ "  \"network\": {\n"
++ "\"port\":3346,\n"
++ "\"nodeFinder\":{\n"
++ "  \"netClusterNodes\": [ " + connectionAddr + " ]\n"
++ "}\n"
++ "  }\n"
++ "}",
+"D2", "{\n"
++ "  \"network\": {\n"
++ "\"port\":3347,\n"
++ "\"nodeFinder\":{\n"
++ "  \"netClusterNodes\": [ " + connectionAddr + " ]\n"
++ "}\n"
++ "  }\n"
++ "}"
+);
 
 /** Cluster nodes. */
-private final List clusterNodes = new ArrayList<>(); // TODO: 
replace with Map (nodeName->node) ?
+private final Map clusterNodes = new HashMap<>();
+
+
+/** Runs after each test sequence. */
+@BeforeEach
+public void beforeAll() {
+log.info("Init cluster.");
+
+List> futures = new ArrayList<>();
+
+nodesCfg.forEach((k, v) -> futures.add(IgnitionManager.start(k, v, 
WORK_DI

[ignite-3] branch ignite-18171 updated: wip. Add todos.

2022-11-24 Thread amashenkov
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/ignite-18171 by this push:
 new 0c0d5ae3ab wip. Add todos.
0c0d5ae3ab is described below

commit 0c0d5ae3aba14eb1ca9912c638109504e15636b0
Author: amashenkov 
AuthorDate: Thu Nov 24 18:36:04 2022 +0300

wip. Add todos.
---
 .../ignite/internal/ItNodeStartStopTest.java   | 141 ++---
 1 file changed, 124 insertions(+), 17 deletions(-)

diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
index a34e3d6523..27c2f4cbb3 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
@@ -42,6 +42,7 @@ import 
org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
 import org.apache.ignite.internal.testframework.WorkDirectory;
 import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
 import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.DynamicContainer;
 import org.junit.jupiter.api.DynamicNode;
@@ -58,9 +59,18 @@ public class ItNodeStartStopTest extends 
BaseIgniteAbstractTest {
 
 private static final String connectionAddr = "\"localhost:3344\", 
\"localhost:3345\", \"localhost:3346\"";
 
+/** Cluster management group node name. */
+private static final String CMG_NODE = "C";
+/** MetaStorage group node name. */
+private static final String METASTORAGE_NODE = "M";
+/** Data node 1. */
+private static final String DATA_NODE = "D";
+/** Data node 2. */
+private static final String DATA_NODE_2 = "D2";
+
 /** Nodes configurations. */
 private static final Map nodesCfg = Map.of(
-"C", "{\n"
+CMG_NODE, "{\n"
 + "  \"network\": {\n"
 + "\"port\":3344,\n"
 + "\"nodeFinder\":{\n"
@@ -68,7 +78,7 @@ public class ItNodeStartStopTest extends 
BaseIgniteAbstractTest {
 + "}\n"
 + "  }\n"
 + "}",
-"M", "{\n"
+METASTORAGE_NODE, "{\n"
 + "  \"network\": {\n"
 + "\"port\":3345,\n"
 + "\"nodeFinder\":{\n"
@@ -76,7 +86,7 @@ public class ItNodeStartStopTest extends 
BaseIgniteAbstractTest {
 + "}\n"
 + "  }\n"
 + "}",
-"D", "{\n"
+DATA_NODE, "{\n"
 + "  \"network\": {\n"
 + "\"port\":3346,\n"
 + "\"nodeFinder\":{\n"
@@ -84,7 +94,7 @@ public class ItNodeStartStopTest extends 
BaseIgniteAbstractTest {
 + "}\n"
 + "  }\n"
 + "}",
-"D2", "{\n"
+DATA_NODE_2, "{\n"
 + "  \"network\": {\n"
 + "\"port\":3347,\n"
 + "\"nodeFinder\":{\n"
@@ -108,7 +118,10 @@ public class ItNodeStartStopTest extends 
BaseIgniteAbstractTest {
 nodesCfg.forEach((k, v) -> futures.add(IgnitionManager.start(k, v, 
WORK_DIR.resolve(k;
 
 //TODO: Fix metastore group
-IgnitionManager.init("C", List.of("C"), List.of("C"), "cluster");
+IgnitionManager.init(CMG_NODE, List.of(CMG_NODE /* METASTORAGE_NODE 
*/), List.of(CMG_NODE), "cluster");
+
+// TODO: Create distribution zones: spans both nodes, spans a single 
node.
+// TODO: Create tables in these distribution zone + add data.
 
 for (CompletableFuture future : futures) {
 assertThat(future, willCompleteSuccessfully());
@@ -130,17 +143,18 @@ public class ItNodeStartStopTest extends 
BaseIgniteAbstractTest {
 
 /** Filter out duplicates and invalid grids. */
 private static BiPredicate> nodeFilter() {
-return (nodeName, grid) -> (!grid.isEmpty() || "C".equals(nodeName)) 
// CMG node always starts first.
-&& (!"D2".equals(nodeName) || grid.contains("D"));  // Data 
nodes are interchangeable.
+return (nodeName, grid) -> (!grid.isEmpty() || 
CMG_NODE.equals(nodeName)) // CMG node always starts first.
+&& (!DATA_NODE_2.equals(nodeName) || 
grid.contains(DATA_NODE));  // Data nodes are interchangeable.
 }
 
 /**
- * Test factory for {@link #testStartSequence()} test method.
+ * Test factory for testing node startup order.
  *
  * @return JUnit tests.
+ * @see #checkNodeStartupSequence() ()
  */
 @TestFactor

[ignite-extensions] branch release/ignite-spark-ext-2.0.0 created (now 868a01a)

2022-11-24 Thread mmuzaf
This is an automated email from the ASF dual-hosted git repository.

mmuzaf pushed a change to branch release/ignite-spark-ext-2.0.0
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git


  at 868a01a  IGNITE-17640 Updated ignite  spring data doc. Fixes #184

No new revisions were added by this update.



[ignite-extensions] branch ignite-18189 updated (bcb3163 -> a69f33f)

2022-11-24 Thread ashapkin
This is an automated email from the ASF dual-hosted git repository.

ashapkin pushed a change to branch ignite-18189
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git


from bcb3163  CR changes
 add a69f33f  Update RELEASE_NOTES.txt

No new revisions were added by this update.

Summary of changes:
 modules/spark-ext/spark/RELEASE_NOTES.txt | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)



[ignite-3] branch main updated: IGNITE-18257 .NET: LINQ: Implement type casts (#1377)

2022-11-24 Thread ptupitsyn
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new 6e50d46e96 IGNITE-18257 .NET: LINQ: Implement type casts (#1377)
6e50d46e96 is described below

commit 6e50d46e9665459559991251b27a2a2f5fdec98d
Author: Pavel Tupitsyn 
AuthorDate: Fri Nov 25 08:23:32 2022 +0300

IGNITE-18257 .NET: LINQ: Implement type casts (#1377)

* Unlike Ignite 2.x, we can't rely on SQL engine to perform type conversion 
in many cases. Emit explicit SQL `cast` when required.
* Remove redundant whitespace in generated SQL.
* Improve `ToSqlTypeName`.
---
 .../Linq/LinqSqlGenerationTests.cs | 10 +--
 .../Linq/LinqTests.Aggregate.cs|  2 +-
 .../Apache.Ignite.Tests/Linq/LinqTests.Cast.cs | 88 ++
 .../Apache.Ignite.Tests/Linq/LinqTests.GroupBy.cs  | 12 ++-
 .../Apache.Ignite.Tests/Linq/LinqTests.Join.cs |  8 +-
 .../Sql/SqlColumnTypeExtensionsTests.cs| 13 +++-
 .../Internal/Linq/IgniteQueryExpressionVisitor.cs  | 25 +++---
 .../Internal/Linq/IgniteQueryModelVisitor.cs   | 16 ++--
 .../Internal/Sql/SqlColumnTypeExtensions.cs| 19 -
 9 files changed, 156 insertions(+), 37 deletions(-)

diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs 
b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs
index df1e2a511d..0a0ba656fd 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqSqlGenerationTests.cs
@@ -60,23 +60,23 @@ public partial class LinqSqlGenerationTests
 
 [Test]
 public void TestSum() =>
-AssertSql("select sum (_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Sum(x 
=> x.Key));
+AssertSql("select sum(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Sum(x 
=> x.Key));
 
 [Test]
 public void TestAvg() =>
-AssertSql("select avg (_T0.KEY) from PUBLIC.tbl1 as _T0", q => 
q.Average(x => x.Key));
+AssertSql("select avg(_T0.KEY) from PUBLIC.tbl1 as _T0", q => 
q.Average(x => x.Key));
 
 [Test]
 public void TestMin() =>
-AssertSql("select min (_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Min(x 
=> x.Key));
+AssertSql("select min(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Min(x 
=> x.Key));
 
 [Test]
 public void TestMax() =>
-AssertSql("select max (_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Max(x 
=> x.Key));
+AssertSql("select max(_T0.KEY) from PUBLIC.tbl1 as _T0", q => q.Max(x 
=> x.Key));
 
 [Test]
 public void TestCount() =>
-AssertSql("select count (*) from PUBLIC.tbl1 as _T0", q => q.Count());
+AssertSql("select count(*) from PUBLIC.tbl1 as _T0", q => q.Count());
 
 [Test]
 public void TestDistinct() =>
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.Aggregate.cs 
b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.Aggregate.cs
index abf6bd8bfb..e186ceac80 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.Aggregate.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.Aggregate.cs
@@ -110,7 +110,7 @@ public partial class LinqTests
 Assert.AreEqual(2, res[2].Max);
 
 StringAssert.Contains(
-"select _T0.KEY, count (*) , sum (_T0.KEY) , avg (_T0.KEY) , min 
(_T0.KEY) , max (_T0.KEY)  " +
+"select _T0.KEY, count(*), sum(_T0.KEY), avg(_T0.KEY), 
min(_T0.KEY), max(_T0.KEY) " +
 "from PUBLIC.TBL_INT32 as _T0 " +
 "group by (_T0.KEY) " +
 "order by (_T0.KEY) asc",
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.Cast.cs 
b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.Cast.cs
new file mode 100644
index 00..f539304012
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Linq/LinqTests.Cast.cs
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Tests.Linq;
+
+using System.Linq;
+using 

[ignite-3] branch main updated: IGNITE-17953 Sql. NPE on some malformed queries - Fixes #1345.

2022-11-24 Thread zstan
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
 new cee8310315 IGNITE-17953 Sql. NPE on some malformed queries - Fixes 
#1345.
cee8310315 is described below

commit cee831031501c36d1d24b1dd72a84747be8f18f6
Author: zstan 
AuthorDate: Fri Nov 25 09:49:34 2022 +0300

IGNITE-17953 Sql. NPE on some malformed queries - Fixes #1345.

Signed-off-by: zstan 
---
 .../client/io/netty/NettyClientConnection.java |  4 +--
 .../runner/app/jdbc/ItJdbcErrorsSelfTest.java  | 40 ++
 .../internal/sql/engine/SqlQueryProcessor.java | 29 ++--
 3 files changed, 68 insertions(+), 5 deletions(-)

diff --git 
a/modules/client/src/main/java/org/apache/ignite/internal/client/io/netty/NettyClientConnection.java
 
b/modules/client/src/main/java/org/apache/ignite/internal/client/io/netty/NettyClientConnection.java
index d21f175b52..a834318d99 100644
--- 
a/modules/client/src/main/java/org/apache/ignite/internal/client/io/netty/NettyClientConnection.java
+++ 
b/modules/client/src/main/java/org/apache/ignite/internal/client/io/netty/NettyClientConnection.java
@@ -21,7 +21,6 @@ import io.netty.buffer.ByteBuf;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.util.AttributeKey;
-import java.io.IOException;
 import java.net.InetSocketAddress;
 import org.apache.ignite.internal.client.io.ClientConnection;
 import org.apache.ignite.internal.client.io.ClientConnectionStateHandler;
@@ -88,9 +87,8 @@ public class NettyClientConnection implements 
ClientConnection {
  * Handles incoming message.
  *
  * @param buf Message.
- * @throws IOException when message can't be decoded.
  */
-void onMessage(ByteBuf buf) throws IOException {
+void onMessage(ByteBuf buf) {
 msgHnd.onMessage(buf);
 }
 
diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ItJdbcErrorsSelfTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ItJdbcErrorsSelfTest.java
index d15d1eed71..f10d2284c1 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ItJdbcErrorsSelfTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/jdbc/ItJdbcErrorsSelfTest.java
@@ -22,6 +22,7 @@ import static 
org.apache.ignite.internal.jdbc.proto.SqlStateCode.INVALID_TRANSAC
 import static 
org.apache.ignite.internal.jdbc.proto.SqlStateCode.UNSUPPORTED_OPERATION;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
@@ -29,6 +30,7 @@ import java.sql.BatchUpdateException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
+import java.sql.Statement;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
@@ -51,6 +53,44 @@ public class ItJdbcErrorsSelfTest extends 
ItJdbcErrorsAbstractSelfTest {
 CLIENT_CONNECTION_FAILED, "Failed to connect to server");
 }
 
+/**
+ * Test that execution of erroneous queries are not stopping execution.
+ * Also check correctness of exception messages.
+ *
+ * @throws SQLException If connection can`t be established.
+ */
+@Test
+public void processMixedQueries() throws SQLException {
+conn = 
DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10800/");
+
+try (Statement stmt = conn.createStatement()) {
+stmt.execute(
+"CREATE TABLE CITIES ("
++ "ID   INT PRIMARY KEY,"
++ "NAME VARCHAR)"
+);
+
+SQLException ex = assertThrows(SQLException.class, () -> 
stmt.execute("non sql stuff"));
+
+assertTrue(ex.getMessage().contains("Failed to parse query"));
+}
+
+try (Statement stmt = conn.createStatement()) {
+stmt.execute(
+"CREATE TABLE ACCOUNTS ("
++ "ACCOUNT_ID INT PRIMARY KEY,"
++ "CITY_IDINT,"
++ "FIRST_NAME VARCHAR,"
++ "LAST_NAME  VARCHAR,"
++ "BALANCEDOUBLE)"
+);
+
+SQLException ex = assertThrows(SQLException.class, () -> 
stmt.execute("CREATE TABLE ACCOUNTS (ACCOUNT_ID INT PRIMARY KEY)"));
+
+assertTrue(ex.getMessage().contains("Table already exists"));
+}
+}
+
 /**
  * Test error code for the case when connectio