Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-14680 Fix incorrect objects comparison #9097

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -166,7 +166,7 @@ else if (obj1 == null)
else if (obj2 == null)
return -nullComparison;
else
return GridH2ValueCacheObject.compareHashOrBytes(obj1, obj2, null);
return GridH2ValueCacheObject.compareHashOrBytes(obj1, obj2);
}
};
}
Expand Down
Expand Up @@ -860,8 +860,8 @@ public void testExceptBigBatch() throws Exception {
* @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();
}

/** */
Expand Down Expand Up @@ -1202,6 +1202,17 @@ class MyKey {
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.
*/
Expand Down Expand Up @@ -1384,14 +1395,14 @@ private List<List<?>> sql(String sql) throws IgniteInterruptedCheckedException {
}

/** */
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;

Expand Down
@@ -0,0 +1,17 @@
# name: test/sql/aggregate/aggregates/test_group_by_many_groups.test_slow
# description: Test GROUP BY with many groups
# group: [aggregates]

statement ok
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
SELECT SUM(i), SUM(sums) FROM (SELECT i, SUM(j) AS sums FROM integers GROUP BY i) tbl1
----
49995000
30000

@@ -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
Expand Down
Expand Up @@ -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

Expand Up @@ -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
Expand Down
Expand Up @@ -163,12 +163,17 @@ public Object getObject(boolean cpy) {
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();

Expand Down