You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pp...@apache.org on 2023/05/02 20:17:26 UTC
[ignite-3] branch main updated: IGNITE-19371 Sql. Prevent the user from using the TIME(STAMP)_WITH_LOCAL_TIME_ZONE types (#1990)
This is an automated email from the ASF dual-hosted git repository.
ppa 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 d11c50bc48 IGNITE-19371 Sql. Prevent the user from using the TIME(STAMP)_WITH_LOCAL_TIME_ZONE types (#1990)
d11c50bc48 is described below
commit d11c50bc48bad404d8c5608c245292443596d17f
Author: Pavel Pereslegin <xx...@gmail.com>
AuthorDate: Tue May 2 23:17:20 2023 +0300
IGNITE-19371 Sql. Prevent the user from using the TIME(STAMP)_WITH_LOCAL_TIME_ZONE types (#1990)
---
.../ignite/internal/sql/engine/ItMetadataTest.java | 21 +++++++++-----
modules/sql-engine/src/main/codegen/config.fmpp | 1 +
.../src/main/codegen/includes/parserImpls.ftl | 32 ++++++++++++++++++++++
.../internal/sql/engine/sql/SqlDdlParserTest.java | 16 +++++++++++
4 files changed, 63 insertions(+), 7 deletions(-)
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItMetadataTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItMetadataTest.java
index 96a480b108..42e112427e 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItMetadataTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItMetadataTest.java
@@ -129,9 +129,14 @@ public class ItMetadataTest extends ClusterPerClassIntegrationTest {
// Datetime types
// ANSI`99 syntax "WITH TIME ZONE" is not supported,
// a "WITH LOCAL TIME ZONE" syntax MUST be used instead.
- + "DATE_C DATE, " + "TIME_C TIME, " + "TIME_C2 TIME(9), " + "TIME_LTZ_C TIME WITH LOCAL TIME ZONE, "
- + "TIME_LTZ_C2 TIME(9) WITH LOCAL TIME ZONE, " + "DATETIME_C TIMESTAMP, " + "DATETIME_C2 TIMESTAMP(9), "
- + "TIMESTAMP_C TIMESTAMP WITH LOCAL TIME ZONE, " + "TIMESTAMP_C2 TIMESTAMP(9) WITH LOCAL TIME ZONE, "
+ + "DATE_C DATE, " + "TIME_C TIME, " + "TIME_C2 TIME(9), "
+ // TODO: IGNITE-19274 Ignite doesn't support the client's time zone yet.
+ // + "TIME_LTZ_C TIME WITH LOCAL TIME ZONE, "
+ // + "TIME_LTZ_C2 TIME(9) WITH LOCAL TIME ZONE, "
+ + "DATETIME_C TIMESTAMP, " + "DATETIME_C2 TIMESTAMP(9), "
+ // TODO: IGNITE-19274 Ignite doesn't support the client's time zone yet.
+ // + "TIMESTAMP_C TIMESTAMP WITH LOCAL TIME ZONE, "
+ // + "TIMESTAMP_C2 TIMESTAMP(9) WITH LOCAL TIME ZONE, "
// Interval types
// TODO: IGNITE-17373: Ignite doesn't support interval types yet.
@@ -190,12 +195,14 @@ public class ItMetadataTest extends ClusterPerClassIntegrationTest {
new MetadataMatcher().name("DATE_C").type(ColumnType.DATE).precision(0).scale(UNDEFINED_SCALE),
new MetadataMatcher().name("TIME_C").type(ColumnType.TIME).precision(0).scale(UNDEFINED_SCALE),
new MetadataMatcher().name("TIME_C2").type(ColumnType.TIME).precision(9).scale(UNDEFINED_SCALE),
- new MetadataMatcher().name("TIME_LTZ_C").type(ColumnType.TIME).precision(0).scale(UNDEFINED_SCALE),
- new MetadataMatcher().name("TIME_LTZ_C2").type(ColumnType.TIME).precision(9).scale(UNDEFINED_SCALE),
+ // TODO: IGNITE-19274 Ignite doesn't support the client's time zone yet.
+ // new MetadataMatcher().name("TIME_LTZ_C").type(ColumnType.TIME).precision(0).scale(UNDEFINED_SCALE),
+ // new MetadataMatcher().name("TIME_LTZ_C2").type(ColumnType.TIME).precision(9).scale(UNDEFINED_SCALE),
new MetadataMatcher().name("DATETIME_C").type(ColumnType.DATETIME).precision(6).scale(UNDEFINED_SCALE),
new MetadataMatcher().name("DATETIME_C2").type(ColumnType.DATETIME).precision(9).scale(UNDEFINED_SCALE),
- new MetadataMatcher().name("TIMESTAMP_C").type(ColumnType.TIMESTAMP).precision(6).scale(UNDEFINED_SCALE),
- new MetadataMatcher().name("TIMESTAMP_C2").type(ColumnType.TIMESTAMP).precision(9).scale(UNDEFINED_SCALE),
+ // TODO: IGNITE-19274 Ignite doesn't support the client's time zone yet.
+ // new MetadataMatcher().name("TIMESTAMP_C").type(ColumnType.TIMESTAMP).precision(6).scale(UNDEFINED_SCALE),
+ // new MetadataMatcher().name("TIMESTAMP_C2").type(ColumnType.TIMESTAMP).precision(9).scale(UNDEFINED_SCALE),
// Interval types
// TODO: IGNITE-17373: Ignite doesn't support interval types yet.
diff --git a/modules/sql-engine/src/main/codegen/config.fmpp b/modules/sql-engine/src/main/codegen/config.fmpp
index a8bcd96d22..57b6c37062 100644
--- a/modules/sql-engine/src/main/codegen/config.fmpp
+++ b/modules/sql-engine/src/main/codegen/config.fmpp
@@ -630,6 +630,7 @@ data: {
# Example: SqlParseTimeStampZ().
dataTypeParserMethods: [
"UuidType(s)",
+ "IgniteDateTimeTypeName()"
]
# Binary operators tokens.
diff --git a/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl b/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl
index d5397216be..ebac86bb61 100644
--- a/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl
+++ b/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl
@@ -560,3 +560,35 @@ SqlLiteral ParseDecimalLiteral():
return IgniteSqlDecimalLiteral.create(value, getPos());
}
}
+
+/**
+* Parse datetime types: date, time, timestamp.
+*
+* TODO Method doesn't recognize '*_WITH_LOCAL_TIME_ZONE' types and should be removed after IGNITE-19274.
+*/
+SqlTypeNameSpec IgniteDateTimeTypeName() :
+{
+ int precision = -1;
+ SqlTypeName typeName;
+ final Span s;
+}
+{
+ <DATE> {
+ typeName = SqlTypeName.DATE;
+ return new SqlBasicTypeNameSpec(typeName, getPos());
+ }
+|
+ <TIME> { s = span(); }
+ precision = PrecisionOpt()
+ {
+ typeName = SqlTypeName.TIME;
+ return new SqlBasicTypeNameSpec(typeName, precision, s.end(this));
+ }
+|
+ <TIMESTAMP> { s = span(); }
+ precision = PrecisionOpt()
+ {
+ typeName = SqlTypeName.TIMESTAMP;
+ return new SqlBasicTypeNameSpec(typeName, precision, s.end(this));
+ }
+}
diff --git a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java
index f6832e3787..371870623b 100644
--- a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java
+++ b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java
@@ -31,6 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.List;
import java.util.Objects;
import java.util.Set;
+import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.apache.calcite.sql.SqlBasicCall;
import org.apache.calcite.sql.SqlIdentifier;
@@ -504,6 +505,21 @@ public class SqlDdlParserTest extends AbstractDdlParserTest {
assertThat(dropIndex.indexName().names, is(List.of("MY_INDEX")));
}
+ /**
+ * Ensures that the user cannot use the TIME_WITH_LOCAL_TIME_ZONE and TIMESTAMP_WITH_LOCAL_TIME_ZONE types for table columns.
+ */
+ // TODO: Remove after https://issues.apache.org/jira/browse/IGNITE-19274 is implemented.
+ @Test
+ public void timestampWithLocalTimeZoneIsNotSupported() {
+ Consumer<String> checker = (query) -> {
+ var ex = assertThrows(SqlException.class, () -> parse(query));
+ assertThat(ex.getMessage(), containsString("Encountered \" \"WITH\""));
+ };
+
+ checker.accept("CREATE TABLE test (ts TIMESTAMP WITH LOCAL TIME ZONE)");
+ checker.accept("CREATE TABLE test (ts TIME WITH LOCAL TIME ZONE)");
+ }
+
private IgniteSqlCreateTable parseCreateTable(String stmt) {
SqlNode node = parse(stmt);