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 495fc7fc17 IGNITE-23139 Sql. Fix failed "test_long_identifiers" test 
(#4346)
495fc7fc17 is described below

commit 495fc7fc17bb7bf54c12f059b3cf7422776bc55c
Author: Evgeniy Stanilovskiy <[email protected]>
AuthorDate: Mon Sep 16 09:27:14 2024 +0300

    IGNITE-23139 Sql. Fix failed "test_long_identifiers" test (#4346)
---
 .../internal/sql/sqllogic/ItSqlLogicTest.java      |  3 +-
 .../sql/sqllogic/ItSqlLogicTestInternalsTest.java  | 90 ++++++++++++++++++++++
 .../apache/ignite/internal/sql/sqllogic/Query.java | 22 ++++--
 .../sql/identifiers/test_long_identifiers.test     |  4 +-
 4 files changed, 108 insertions(+), 11 deletions(-)

diff --git 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java
 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java
index c0eb52ed2d..0053c4cddd 100644
--- 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java
+++ 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTest.java
@@ -348,6 +348,7 @@ public class ItSqlLogicTest extends BaseIgniteAbstractTest {
 
         for (IgniteServer node : nodes) {
             assertThat(node.waitForInitAsync(), willCompleteSuccessfully());
+            NODES.add(node);
 
             IgniteImpl ignite = unwrapIgniteImpl(node.api());
             CLUSTER_NODES.add(ignite);
@@ -367,7 +368,7 @@ public class ItSqlLogicTest extends BaseIgniteAbstractTest {
         LOG.info(">>> Cluster is stopped.");
     }
 
-    private static final class TestRunnerRuntime implements RunnerRuntime {
+    static final class TestRunnerRuntime implements RunnerRuntime {
 
         /**
          * {@inheritDoc}
diff --git 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTestInternalsTest.java
 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTestInternalsTest.java
new file mode 100644
index 0000000000..de9a8ab8b9
--- /dev/null
+++ 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/ItSqlLogicTestInternalsTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.sqllogic;
+
+import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrowsWithCause;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.List;
+import org.apache.ignite.internal.lang.IgniteStringBuilder;
+import 
org.apache.ignite.internal.sql.sqllogic.ItSqlLogicTest.TestRunnerRuntime;
+import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.apache.ignite.sql.IgniteSql;
+import org.junit.jupiter.api.Test;
+
+/** Sql logic internals. */
+@SuppressWarnings("ThrowableNotThrown")
+public class ItSqlLogicTestInternalsTest extends BaseIgniteAbstractTest {
+    /** Check if expected and returned results are mismatched, correct 
exception with list of returned results is raised. */
+    @Test
+    public void returnResults() throws Exception {
+        TestRunnerRuntime runnerRuntime = mock(TestRunnerRuntime.class);
+        IgniteSql sql = mock(IgniteSql.class);
+        when(runnerRuntime.sql()).thenReturn(sql);
+        ScriptContext ctx = new ScriptContext(runnerRuntime);
+
+        File file = generateTempFile();
+
+        try {
+            IgniteStringBuilder sb = new IgniteStringBuilder();
+            sb.app("query II").nl();
+            sb.app("SELECT c1, c2 FROM (VALUES(1, 2), (2, 3)) t(c1, c2) ORDER 
BY c1").nl();
+            sb.app("----").nl();
+            sb.app("2\t3").nl();
+            sb.app("1\t2").nl();
+
+            Files.writeString(file.toPath(), sb.toString());
+
+            try (Script script = new Script(file.toPath(), ctx)) {
+                Query qry = new Query(script, ctx, new String[]{"query", 
"II"});
+                List<List<?>> res = List.of(List.of(1, 2), List.of(2, 3));
+
+                assertThrowsWithCause(
+                        () -> qry.checkResultTuples(ctx, res),
+                        AssertionError.class,
+                        "Invalid results"
+                );
+
+                List<List<?>> resMore = List.of(List.of(1, 1), List.of(1, 2), 
List.of(2, 3));
+
+                assertThrowsWithCause(
+                        () -> qry.checkResultTuples(ctx, resMore),
+                        AssertionError.class,
+                        "Invalid results rows count"
+                );
+            }
+        } finally {
+            Files.delete(file.toPath());
+        }
+    }
+
+    private static File generateTempFile() throws IOException {
+        String tmpDir = System.getProperty("java.io.tmpdir");
+        String fileName = "test_sqllogic_test.test";
+        File f = new File(tmpDir, fileName);
+        if (f.exists()) {
+            assert !f.isDirectory();
+            Files.delete(f.toPath());
+        }
+        return f;
+    }
+}
diff --git 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/Query.java
 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/Query.java
index 2f6dccd0d5..08acb97dfd 100644
--- 
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/Query.java
+++ 
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/sqllogic/Query.java
@@ -307,7 +307,7 @@ final class Query extends Command {
         }
     }
 
-    private void checkResultTuples(ScriptContext ctx, List<List<?>> res) {
+    void checkResultTuples(ScriptContext ctx, List<List<?>> res) {
         if (expectedRes.size() != res.size()) {
             throw new AssertionError("Invalid results rows count at: " + 
posDesc
                     + ". [expectedRows=" + expectedRes.size() + ", 
actualRows=" + res.size()
@@ -327,13 +327,19 @@ final class Query extends Command {
                 String expectStrValRaw = expectedRow.get(j);
                 String expectStrVal = ctx.replaceVars(expectStrValRaw);
 
-                checkEquals(ctx,
-                        "Not expected result at: " + posDesc
-                                + ". [row=" + i + ", col=" + j
-                                + ", expected=" + expectStrVal + ", actual=" + 
resultToString(ctx, row.get(j)) + ']',
-                        expectStrVal,
-                        row.get(j)
-                );
+                try {
+                    checkEquals(ctx,
+                            "Not expected result at: " + posDesc
+                                    + ". [row=" + i + ", col=" + j
+                                    + ", expected=" + expectStrVal + ", 
actual=" + resultToString(ctx, row.get(j)) + ']',
+                            expectStrVal,
+                            row.get(j)
+                    );
+                } catch (AssertionError ex) {
+                    AssertionError extended = new AssertionError("Invalid 
results: " + res);
+                    ex.addSuppressed(extended);
+                    throw ex;
+                }
             }
         }
     }
diff --git 
a/modules/sql-engine/src/integrationTest/sql/identifiers/test_long_identifiers.test
 
b/modules/sql-engine/src/integrationTest/sql/identifiers/test_long_identifiers.test
index e39c6af3d8..15d3f69b4f 100644
--- 
a/modules/sql-engine/src/integrationTest/sql/identifiers/test_long_identifiers.test
+++ 
b/modules/sql-engine/src/integrationTest/sql/identifiers/test_long_identifiers.test
@@ -148,7 +148,7 @@ SELECT 
columnAlias_veryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooo
 statement error: Length of identifier
 SELECT 
columnAlias_veryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf129Characters
 FROM (SELECT 1 
columnAlias_veryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf129Characters);
 
-query I
+query I rowsort
 SELECT 
tableName_veryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf128Characters.keyColumnName_veryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf128Characters
 FROM 
tableName_veryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf128Characters;
 ----
 1
@@ -163,7 +163,7 @@ SELECT * FROM (SELECT 1) as 
tableAlias_veryLoooooooooooooooooooooooooooooooooooo
 statement error: Length of identifier
 SELECT * FROM (SELECT 1) as 
tableAlias_veryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf129Characters;
 
-query I
+query I rowsort
 SELECT 
tableAlias_veryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf128Characters.id
 FROM t as 
tableAlias_veryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongIdentifierOf128Characters;
 ----
 1

Reply via email to