You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2021/06/17 09:29:56 UTC
[ignite] branch sql-calcite updated: IGNITE-14724 Fix create table
with 'date' datatype - Fixes #9111.
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 787ae95 IGNITE-14724 Fix create table with 'date' datatype - Fixes #9111.
787ae95 is described below
commit 787ae95a4f057f51310ac679537e6fbb86164217
Author: Aleksey Plekhanov <pl...@gmail.com>
AuthorDate: Thu Jun 17 12:28:29 2021 +0300
IGNITE-14724 Fix create table with 'date' datatype - Fixes #9111.
Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
.../query/calcite/exec/ddl/DdlCommandHandler.java | 2 +-
.../integration/TableDdlIntegrationTest.java | 62 +++++++++++
.../query/calcite/jdbc/JdbcQueryTest.java | 10 +-
.../sql/aggregate/aggregates/test_perfect_ht.test | 113 +++++++++++++++++++++
.../aggregates/test_perfect_ht.test_ignore | 7 +-
5 files changed, 185 insertions(+), 9 deletions(-)
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ddl/DdlCommandHandler.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ddl/DdlCommandHandler.java
index 76e6475..befb58f 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ddl/DdlCommandHandler.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ddl/DdlCommandHandler.java
@@ -183,7 +183,7 @@ public class DdlCommandHandler {
for (ColumnDefinition col : cmd.columns()) {
String name = col.name();
- Type javaType = tf.getJavaClass(col.type());
+ Type javaType = tf.getResultClass(col.type());
String typeName = javaType instanceof Class ? ((Class<?>)javaType).getName() : javaType.getTypeName();
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java
index eef868d..4bbfa89 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java
@@ -16,6 +16,10 @@
*/
package org.apache.ignite.internal.processors.query.calcite.integration;
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -135,6 +139,64 @@ public class TableDdlIntegrationTest extends GridCommonAbstractTest {
}
/**
+ * Creates table with columns of different data types and check DML on these columns.
+ */
+ @Test
+ public void createTableDifferentDataTypes() {
+ executeSql("create table my_table (" +
+ "id int primary key, " +
+ "c1 varchar, " +
+ "c2 date, " +
+ "c3 time, " +
+ "c4 timestamp, " +
+ "c5 integer, " +
+ "c6 bigint, " +
+ "c7 smallint, " +
+ "c8 tinyint, " +
+ "c9 boolean, " +
+ "c10 double, " +
+ "c11 float, " +
+ "c12 decimal(20, 10) " +
+ ")");
+
+ executeSql("insert into my_table values (" +
+ "0, " +
+ "'test', " +
+ "date '2021-01-01', " +
+ "time '12:34:56', " +
+ "timestamp '2021-01-01 12:34:56', " +
+ "1, " +
+ "9876543210, " +
+ "3, " +
+ "4, " +
+ "true, " +
+ "123.456, " +
+ "654.321, " +
+ "1234567890.1234567890" +
+ ")");
+
+ List<List<?>> res = executeSql("select * from my_table");
+
+ assertEquals(1, res.size());
+
+ List<?> row = res.get(0);
+
+ assertEquals(0, row.get(0));
+ assertEquals("test", row.get(1));
+ assertEquals(Date.valueOf("2021-01-01"), row.get(2));
+ assertEquals(Time.valueOf("12:34:56"), row.get(3));
+ assertEquals(Timestamp.valueOf("2021-01-01 12:34:56"), row.get(4));
+ assertEquals(1, row.get(5));
+ assertEquals(9876543210L, row.get(6));
+ assertEquals((short)3, row.get(7));
+ assertEquals((byte)4, row.get(8));
+ assertEquals(Boolean.TRUE, row.get(9));
+ assertEquals(123.456d, row.get(10));
+ assertEquals(654.321f, row.get(11));
+ assertEquals(new BigDecimal("1234567890.1234567890"), row.get(12));
+ }
+
+ /**
* Creates table with all possible options except template,
* and verifies created cache.
*/
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java
index bcc369b..c9efa83 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcQueryTest.java
@@ -144,11 +144,11 @@ public class JdbcQueryTest extends GridCommonAbstractTest {
assertEquals(Types.VARCHAR, md.getColumnType(8));
assertEquals(Types.FLOAT, md.getColumnType(9));
assertEquals(Types.DOUBLE, md.getColumnType(10));
- assertEquals(Types.INTEGER, md.getColumnType(11));
- assertEquals(Types.BIGINT, md.getColumnType(12));
- assertEquals(Types.BIGINT, md.getColumnType(13));
- assertEquals(Types.BIGINT, md.getColumnType(14));
- assertEquals(Types.INTEGER, md.getColumnType(15));
+ assertEquals(Types.TIME, md.getColumnType(11));
+ assertEquals(Types.TIMESTAMP, md.getColumnType(12));
+ assertEquals(Types.TIMESTAMP, md.getColumnType(13));
+ assertEquals(Types.TIMESTAMP, md.getColumnType(14));
+ assertEquals(Types.DATE, md.getColumnType(15));
}
stmt.execute("DROP TABLE t1");
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 488e583..aab3c6e 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
@@ -62,3 +62,116 @@ SELECT COUNT(DISTINCT i), MIN(i), MAX(i), SUM(i) / COUNT(i) FROM (SELECT t::SMAL
----
65535 -32767 32767 0
+# test result ordering of perfect HT
+statement ok
+PRAGMA disable_verification
+
+statement ok
+create table dates(d date);
+
+statement ok
+insert into dates select date '1992-01-01' + interval x months as d from table(system_range(0, 99));
+
+query II
+select extract(year from d), extract(month from d) from dates group by extract(year from d), extract(month from d) order by 1, 2;
+----
+1992 1
+1992 2
+1992 3
+1992 4
+1992 5
+1992 6
+1992 7
+1992 8
+1992 9
+1992 10
+1992 11
+1992 12
+1993 1
+1993 2
+1993 3
+1993 4
+1993 5
+1993 6
+1993 7
+1993 8
+1993 9
+1993 10
+1993 11
+1993 12
+1994 1
+1994 2
+1994 3
+1994 4
+1994 5
+1994 6
+1994 7
+1994 8
+1994 9
+1994 10
+1994 11
+1994 12
+1995 1
+1995 2
+1995 3
+1995 4
+1995 5
+1995 6
+1995 7
+1995 8
+1995 9
+1995 10
+1995 11
+1995 12
+1996 1
+1996 2
+1996 3
+1996 4
+1996 5
+1996 6
+1996 7
+1996 8
+1996 9
+1996 10
+1996 11
+1996 12
+1997 1
+1997 2
+1997 3
+1997 4
+1997 5
+1997 6
+1997 7
+1997 8
+1997 9
+1997 10
+1997 11
+1997 12
+1998 1
+1998 2
+1998 3
+1998 4
+1998 5
+1998 6
+1998 7
+1998 8
+1998 9
+1998 10
+1998 11
+1998 12
+1999 1
+1999 2
+1999 3
+1999 4
+1999 5
+1999 6
+1999 7
+1999 8
+1999 9
+1999 10
+1999 11
+1999 12
+2000 1
+2000 2
+2000 3
+2000 4
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 14072bb..8dba3ba 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
@@ -3,7 +3,8 @@
# group: [aggregates]
# Ignored: https://issues.apache.org/jira/browse/IGNITE-14555
# Ignored: https://issues.apache.org/jira/browse/IGNITE-14636
-# Ignored: https://issues.apache.org/jira/browse/IGNITE-14724
+# Ignored: https://issues.apache.org/jira/browse/IGNITE-14730
+# Ignored: https://issues.apache.org/jira/browse/IGNITE-14885
statement ok
PRAGMA enable_verification
@@ -70,10 +71,10 @@ statement ok
PRAGMA disable_verification
statement ok
-create table dates as select date '1992-01-01' + concat(i, ' months')::interval as d from range(100) tbl(i);
+create table dates as select date '1992-01-01' + concat(x, ' months')::interval as d from table(system_range(0, 99));
query II
-select extract(year from d), extract(month from d) from dates group by 1, 2;
+select extract(year from d), extract(month from d) from dates group by 1, 2 order by 1, 2;
----
1992 1
1992 2