This is an automated email from the ASF dual-hosted git repository.
alexpl pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/sql-calcite by this push:
new 7b67d89 IGNITE-14680 Fix incorrect objects comparison - Fixes #9097.
7b67d89 is described below
commit 7b67d89f9b07a1763904bb5b31efd09fce8e0fe2
Author: Aleksey Plekhanov <[email protected]>
AuthorDate: Tue May 18 16:20:31 2021 +0300
IGNITE-14680 Fix incorrect objects comparison - Fixes #9097.
Signed-off-by: Aleksey Plekhanov <[email protected]>
---
.../query/calcite/exec/exp/ExpressionFactoryImpl.java | 2 +-
.../query/calcite/CalciteQueryProcessorTest.java | 19 +++++++++++++++----
...low_ignore => test_group_by_many_groups.test_slow} | 7 ++++---
.../test_group_by_many_groups.test_slow_ignore | 3 +--
.../sql/aggregate/aggregates/test_perfect_ht.test | 12 ++++++++++++
.../aggregate/aggregates/test_perfect_ht.test_ignore | 3 ++-
.../query/h2/opt/GridH2ValueCacheObject.java | 9 +++++++--
7 files changed, 42 insertions(+), 13 deletions(-)
diff --git
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java
index 4da32f9..3b6cc9e 100644
---
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java
+++
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java
@@ -166,7 +166,7 @@ public class ExpressionFactoryImpl<Row> implements
ExpressionFactory<Row> {
else if (obj2 == null)
return -nullComparison;
else
- return GridH2ValueCacheObject.compareHashOrBytes(obj1,
obj2, null);
+ return GridH2ValueCacheObject.compareHashOrBytes(obj1,
obj2);
}
};
}
diff --git
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
index c80118a..edb10a2 100644
---
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
+++
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
@@ -860,8 +860,8 @@ public class CalciteQueryProcessorTest extends
GridCommonAbstractTest {
* @param node Node.
* @param sql Statement.
*/
- protected List<List<?>> execute(IgniteEx node, String sql) {
- return node.context().query().querySqlFields(new
SqlFieldsQuery(sql).setSchema("PUBLIC"), true).getAll();
+ protected List<List<?>> execute(IgniteEx node, String sql, Object... args)
{
+ return node.context().query().querySqlFields(new
SqlFieldsQuery(sql).setSchema("PUBLIC").setArgs(args), true).getAll();
}
/** */
@@ -1202,6 +1202,17 @@ public class CalciteQueryProcessorTest extends
GridCommonAbstractTest {
assertEquals(ImmutableIntList.of(3),
tblMap.get("MY_TBL_2").descriptor().distribution().getKeys());
}
+ /** */
+ @Test
+ public void testSequentialInserts() throws Exception {
+ sql("CREATE TABLE t(x INTEGER)", true);
+
+ for (int i = 0; i < 10_000; i++)
+ sql("INSERT INTO t VALUES (?)", true, i);
+
+ assertEquals(10_000L, sql("SELECT count(*) FROM t").get(0).get(0));
+ }
+
/**
* Verifies that table modification events are passed to a calcite schema
modification listener.
*/
@@ -1384,14 +1395,14 @@ public class CalciteQueryProcessorTest extends
GridCommonAbstractTest {
}
/** */
- private List<List<?>> sql(String sql, boolean noCheck) throws
IgniteInterruptedCheckedException {
+ private List<List<?>> sql(String sql, boolean noCheck, Object...args)
throws IgniteInterruptedCheckedException {
QueryEngine engineSrv = Commons.lookupComponent(grid(0).context(),
QueryEngine.class);
assertTrue(client.configuration().isClientMode());
QueryEngine engineCli = Commons.lookupComponent(client.context(),
QueryEngine.class);
- List<FieldsQueryCursor<List<?>>> cursorsCli = engineCli.query(null,
"PUBLIC", sql);
+ List<FieldsQueryCursor<List<?>>> cursorsCli = engineCli.query(null,
"PUBLIC", sql, args);
List<List<?>> allSrv;
diff --git
a/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow_ignore
b/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow
similarity index 52%
copy from
modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow_ignore
copy to
modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow
index 92891f4..9b22d09 100644
---
a/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow_ignore
+++
b/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow
@@ -1,11 +1,12 @@
# name: test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow
# description: Test GROUP BY with many groups
# group: [aggregates]
-# Ignored: https://issues.apache.org/jira/browse/IGNITE-14680
-# Ignored: https://issues.apache.org/jira/browse/IGNITE-14555
statement ok
-CREATE TABLE integers AS SELECT i, 1 AS j FROM range(0, 10000, 1) t1(i) UNION
ALL SELECT i, 2 j FROM range(0, 10000, 1) t1(i);
+CREATE TABLE integers(i INTEGER, j INTEGER);
+
+statement ok
+INSERT INTO integers SELECT x, 1 FROM table(system_range(0, 9999, 1)) UNION
ALL SELECT x, 2 FROM table(system_range(0, 9999, 1));
query RR
diff --git
a/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow_ignore
b/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow_ignore
index 92891f4..3d01e7f 100644
---
a/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow_ignore
+++
b/modules/calcite/src/test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow_ignore
@@ -1,11 +1,10 @@
# name: test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow
# description: Test GROUP BY with many groups
# group: [aggregates]
-# Ignored: https://issues.apache.org/jira/browse/IGNITE-14680
# Ignored: https://issues.apache.org/jira/browse/IGNITE-14555
statement ok
-CREATE TABLE integers AS SELECT i, 1 AS j FROM range(0, 10000, 1) t1(i) UNION
ALL SELECT i, 2 j FROM range(0, 10000, 1) t1(i);
+CREATE TABLE integers AS SELECT x AS i, 1 AS j FROM table(system_range(0,
9999, 1)) UNION ALL SELECT x AS i, 2 j FROM table(system_range(0, 9999, 1));
query RR
diff --git
a/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test
b/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test
index 4884c3b..488e583 100644
--- a/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test
+++ b/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test
@@ -50,3 +50,15 @@ SELECT COUNT(DISTINCT i), MIN(i), MAX(i), SUM(i) / COUNT(i)
FROM (SELECT t::TINY
----
255 -127 127 0
+# now do the same with a single smallint column
+statement ok
+CREATE TABLE smallints (t SMALLINT)
+
+statement ok
+INSERT INTO smallints SELECT x::SMALLINT::VARCHAR AS t FROM
table(system_range(-32767, 32767));
+
+query IIII
+SELECT COUNT(DISTINCT i), MIN(i), MAX(i), SUM(i) / COUNT(i) FROM (SELECT
t::SMALLINT i FROM smallints GROUP BY t)
+----
+65535 -32767 32767 0
+
diff --git
a/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test_ignore
b/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test_ignore
index 769c329..14072bb 100644
---
a/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test_ignore
+++
b/modules/calcite/src/test/sql/aggregate/aggregates/test_perfect_ht.test_ignore
@@ -2,7 +2,8 @@
# description: Test aggregates that can trigger a perfect HT
# group: [aggregates]
# Ignored: https://issues.apache.org/jira/browse/IGNITE-14555
-# Ignored: https://issues.apache.org/jira/browse/IGNITE-14680
+# Ignored: https://issues.apache.org/jira/browse/IGNITE-14636
+# Ignored: https://issues.apache.org/jira/browse/IGNITE-14724
statement ok
PRAGMA enable_verification
diff --git
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
index 9f33e4e..295ffb8 100644
---
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
+++
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
@@ -163,12 +163,17 @@ public class GridH2ValueCacheObject extends Value {
return o1.getClass().getName().compareTo(o2.getClass().getName());
}
- return compareHashOrBytes(o1, o2, (v1, v2) ->
Bits.compareNotNullSigned(((Value)v1).getBytesNoCopy(),
+ return compareHashOrBytes(this, v, (v1, v2) ->
Bits.compareNotNullSigned(((Value)v1).getBytesNoCopy(),
((Value)v2).getBytesNoCopy()));
}
/** Compare hash codes. */
- public static int compareHashOrBytes(Object o1, Object o2,
Comparator<Object> comp) {
+ public static int compareHashOrBytes(Object o1, Object o2) {
+ return compareHashOrBytes(o1, o2, null);
+ }
+
+ /** Compare hash codes. */
+ private static int compareHashOrBytes(Object o1, Object o2,
Comparator<Object> comp) {
int h1 = o1.hashCode();
int h2 = o2.hashCode();