IGNITE-21953: Cover SQL E021-01(Character string types. CHARACTER data type) feature by tests (#3660)
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItPublicApiColocationTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItPublicApiColocationTest.java
index 2325d98..16d0948 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItPublicApiColocationTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItPublicApiColocationTest.java
@@ -125,7 +125,7 @@
@Disabled("https://issues.apache.org/jira/browse/IGNITE-17557")
@ParameterizedTest(name = "types=" + ARGUMENTS_PLACEHOLDER)
@MethodSource("twoColumnsParameters")
- public void colocationTwoColumns(NativeTypeSpec t0, NativeTypeSpec t1) throws Exception {
+ public void colocationTwoColumns(NativeTypeSpec t0, NativeTypeSpec t1) {
sql(String.format("create table test0(id0 %s, id1 %s, v INTEGER, primary key(id0, id1))", sqlTypeName(t0), sqlTypeName(t1)));
sql(String.format(
@@ -139,9 +139,9 @@
sql("insert into test1 values(?, ?, ?, ?)", i, generateValueByType(i, t0), generateValueByType(i, t1), 0);
}
- int parts = ((TableViewInternal) CLUSTER.aliveNode().tables().table("test0")).internalTable().partitions();
- TableViewInternal tbl0 = (TableViewInternal) CLUSTER.aliveNode().tables().table("test0");
- TableViewInternal tbl1 = (TableViewInternal) CLUSTER.aliveNode().tables().table("test1");
+ int parts = unwrapTableViewInternal(CLUSTER.aliveNode().tables().table("test0")).internalTable().partitions();
+ TableViewInternal tbl0 = unwrapTableViewInternal(CLUSTER.aliveNode().tables().table("test0"));
+ TableViewInternal tbl1 = unwrapTableViewInternal(CLUSTER.aliveNode().tables().table("test1"));
Function<Tuple, Tuple> tupleColocationExtract = (t) -> {
Tuple ret = Tuple.create();
@@ -249,9 +249,9 @@
case INT64:
return (long) i;
case FLOAT:
- return (float) i + ((float) i / 1000);
+ return i + ((float) i / 1000);
case DOUBLE:
- return (double) i + ((double) i / 1000);
+ return i + ((double) i / 1000);
case DECIMAL:
return BigDecimal.valueOf((double) i + ((double) i / 1000));
case UUID:
diff --git a/modules/sql-engine/src/integrationTest/sql/order/test_order_same_value.test_slow_ignore b/modules/sql-engine/src/integrationTest/sql/order/test_order_same_value.test
similarity index 95%
rename from modules/sql-engine/src/integrationTest/sql/order/test_order_same_value.test_slow_ignore
rename to modules/sql-engine/src/integrationTest/sql/order/test_order_same_value.test
index e80f4f8..829a7a3 100644
--- a/modules/sql-engine/src/integrationTest/sql/order/test_order_same_value.test_slow_ignore
+++ b/modules/sql-engine/src/integrationTest/sql/order/test_order_same_value.test
@@ -1,7 +1,6 @@
# name: test/sql/order/test_order_same_value.test_slow
# description: Test ordering the same value several times
# group: [order]
-# Ignored: https://issues.apache.org/jira/browse/IGNITE-18379
statement ok
PRAGMA enable_verification
diff --git a/modules/sql-engine/src/integrationTest/sql/types/char/test_char.test b/modules/sql-engine/src/integrationTest/sql/types/char/test_char.test
new file mode 100644
index 0000000..6ee2a3c
--- /dev/null
+++ b/modules/sql-engine/src/integrationTest/sql/types/char/test_char.test
@@ -0,0 +1,56 @@
+# name: test/sql/types/char/test_char.test
+# description: E021-01 Character string types. CHARACTER data type base tests.
+# group: [char]
+
+statement ok
+CREATE TABLE t1(c1 CHAR(5));
+
+statement ok
+INSERT INTO t1 VALUES(NULL);
+
+# possibility to keep null value
+query T rowsort
+SELECT * from t1;
+----
+NULL
+
+statement ok
+INSERT INTO t1 VALUES('1 '), (' 2'), ('');
+
+# Check concatenation with function ||
+query T rowsort
+SELECT ' prefix' || c1 || 'trailing ' FROM t1;
+----
+ prefix 2trailing
+ prefix1 trailing
+ prefixtrailing
+NULL
+
+statement ok
+CREATE TABLE t2(c1 CHAR(3));
+
+statement ok
+INSERT INTO t2 VALUES ('123'),('2'),('1');
+
+# for the purposes of the comparison, the shorter value is effectively extended to the length
+# of the longer by concatenation of <space>s on the right
+
+skipif ignite3
+# JIRA https://issues.apache.org/jira/browse/IGNITE-22106
+query T
+SELECT t1.c1 || t2.c1 FROM t1, t2 where t1.c1=t2.c1;
+----
+11
+
+skipif ignite3
+# JIRA https://issues.apache.org/jira/browse/IGNITE-22106
+query T
+SELECT t1.c1 || t2.c1 FROM t1 join t2 ON (t1.c1=t2.c1);
+----
+11
+
+query TTTT
+SELECT 'a' = 'a' AS t1, 'a' = 'b' AS t2, 'a' = 'a ' AS t3, 'a' = ' a' AS t4;
+----
+true false true false
+
diff --git a/modules/sql-engine/src/integrationTest/sql/types/char/test_char_character_set.test b/modules/sql-engine/src/integrationTest/sql/types/char/test_char_character_set.test
new file mode 100644
index 0000000..a6a1c7d
--- /dev/null
+++ b/modules/sql-engine/src/integrationTest/sql/types/char/test_char_character_set.test
@@ -0,0 +1,60 @@
+# name: test/sql/types/char/test_char_character_set.test
+# description: E021-01 Character string types. CHARACTER SET tests
+# group: [char]
+
+# Incorrect name of charset
+statement error
+CREATE TABLE t_incorrect(C1 CHAR CHARACTER SET UTF_8);
+
+statement ok
+CREATE TABLE t_default (c1 CHAR, c2 CHARACTER, c3 CHAR(3), c4 CHARACTER(3));
+
+statement ok
+CREATE TABLE t_utf8 (c1 CHAR CHARACTER SET UTF8, c2 CHARACTER CHARACTER SET UTF8, c3 CHAR(3) CHARACTER SET UTF8, c4 CHARACTER(3) CHARACTER SET UTF8);
+
+statement ok
+CREATE TABLE t_latin1 (c1 CHAR CHARACTER SET LATIN1, c2 CHARACTER CHARACTER SET LATIN1, c3 CHAR(3) CHARACTER SET LATIN1, c4 CHARACTER(3) CHARACTER SET LATIN1);
+
+statement ok
+INSERT INTO t_default VALUES('1', '2', '🍞', 'Ю44');
+
+statement ok
+INSERT INTO t_utf8 VALUES('1', '2', '🍞', 'Ю44');
+
+# Must fail due to use symbol doesn't belong to charset of column
+skipif ignite3
+# https://issues.apache.org/jira/browse/IGNITE-22100
+statement error
+INSERT INTO t_latin1 VALUES('1', '2', '🍞', 'Ю44');
+
+# Must fail due to different character set
+skipif ignite3
+# https://issues.apache.org/jira/browse/IGNITE-22100
+statement error
+INSERT INTO t_latin1 SELECT * FROM t_utf8;
+
+# Must fail due to different character set
+skipif ignite3
+# https://issues.apache.org/jira/browse/IGNITE-22100
+statement error
+INSERT INTO t_utf8 SELECT * FROM t_latin1;
+
+query I
+SELECT count(*) from t_utf8 t1, t_default t2 where t1.c1=t2.c1;
+----
+1
+
+query I
+SELECT count(*) from t_utf8 t1, t_default t2 where t1.c2=t2.c2;
+----
+1
+
+query T
+SELECT count(*) from t_utf8 t1 join t_default t2 on (t1.c3=t2.c3);
+----
+1
+
+query T
+SELECT count(*) from t_utf8 t1 join t_default t2 on (t1.c4=t2.c4);
+----
+1
diff --git a/modules/sql-engine/src/integrationTest/sql/types/char/test_char_length.test b/modules/sql-engine/src/integrationTest/sql/types/char/test_char_length.test
new file mode 100644
index 0000000..243dcf2
--- /dev/null
+++ b/modules/sql-engine/src/integrationTest/sql/types/char/test_char_length.test
@@ -0,0 +1,72 @@
+# name: test/sql/types/char/test_char_length.test
+# description: E021-01 Character string types. CHARACTER data type. Check length of the CHAR datatype.
+# group: [char]
+
+# length shouldn't be negative;
+statement error
+CREATE TABLE t_negative(c1 CHAR(-1));
+
+# length shouldn't be zero;
+skipif ignite3
+# https://issues.apache.org/jira/browse/IGNITE-22120
+statement ok
+CREATE TABLE t_zero(c1 CHAR(0));
+
+statement ok
+CREATE TABLE t_default(c1 CHAR);
+
+# If <length> is omitted, then a <length> of 1 (one) is implicit.
+skipif ignite3
+# https://issues.apache.org/jira/browse/IGNITE-18492
+statement error
+INSERT INTO t_default VALUES('12');
+
+statement ok
+INSERT INTO t_default VALUES('1');
+
+# possibility to insert empty string
+statement ok
+INSERT INTO t_default VALUES('');
+
+
+statement ok
+CREATE TABLE t_three (c1 CHAR(3), c2 CHARACTER(3));
+
+# MUST FAIL due to length
+skipif ignite3
+# https://issues.apache.org/jira/browse/IGNITE-18492
+statement error
+INSERT INTO t_three VALUES('1', '4444');
+
+statement ok
+INSERT INTO t_three VALUES('1', '4444'::CHAR(3));
+
+statement ok
+DELETE FROM t_three WHERE c2 = '444';
+
+# MUST FAIL due to length
+skipif ignite3
+# https://issues.apache.org/jira/browse/IGNITE-18492
+statement error
+INSERT INTO t_three VALUES('1234', '444');
+
+statement ok
+INSERT INTO t_three VALUES('123', '456'), ('1 ', '1'), (' 2 ', '2'), (' 3','3');
+
+# check keep spaces as prefix and trailing symbols
+query TT rowsort
+SELECT * FROM t_three;
+----
+ 3 3
+ 2 2
+1 1
+123 456
+
+# check correct length of data
+query II rowsort
+SELECT LENGTH(c1), LENGTH(c2) FROM t_three;
+----
+3 1
+3 1
+3 1
+3 3