You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2024/04/04 17:56:07 UTC
[PR] IGNITE-19274 [ignite-3]
xtern opened a new pull request, #3558:
URL: https://github.com/apache/ignite-3/pull/3558
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557340499
##########
modules/sql-engine/src/integrationTest/sql/types/time/time_parsing.test:
##########
@@ -22,8 +22,8 @@ SELECT '14:42:04.999'::TIME(3)::VARCHAR
----
14:42:04.999
+# trailing zeros get truncated
query I
-SELECT '14:42:04.999'::TIME(6)::VARCHAR
+SELECT '14:42:04.000000'::TIME(6)::VARCHAR
Review Comment:
After Andrew comment I decided to copy original test from `time_parsing_ignore.test` :thinking:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557420442
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteSqlFunctions.java:
##########
@@ -574,6 +575,75 @@ public static Long subtractTimeZoneOffset(long timestamp, TimeZone timeZone) {
return timestamp - offset;
}
+ /**
+ * Helper for CAST({timestamp} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimestampToString(long timestamp, int precision) {
Review Comment:
> is it critical that we append trailing zeros ?
Without removing trailing zeros current conversion
from TIMESTAMP to TIMESTAMP TZ fails in `TimestampString#normalize` method.
For example for string `2008-01-01 00:00:01.000000`
It removes all zeros and got `2008-01-01 00:00:01.` and then expects that after '.' will be at least one digit.
I don't think this is critical since we can implement our own TIMESTAMP to TIMESTAMP_TZ conversion.
> it made for consistency between different temporal tests conversion
From my point of view, yes, it makes the current behavior more consistent.
The following queries:
```
SELECT (TIMESTAMP '2008-01-01 00:00:01.001')::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP WITH LOCAL TIME ZONE::VARCHAR
SELECT (TIMESTAMP WITH LOCAL TIME ZONE '2008-01-01 00:00:01.001')::VARCHAR
```
Output the following result before this change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001000
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
After this change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
p.s. PostgreSQL result
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001+00
2008-01-01 00:00:01.001+00
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1554070793
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteSqlFunctions.java:
##########
@@ -574,6 +575,75 @@ public static Long subtractTimeZoneOffset(long timestamp, TimeZone timeZone) {
return timestamp - offset;
}
+ /**
+ * Helper for CAST({timestamp} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimestampToString(long timestamp, int precision) {
+ IgniteStringBuilder buf = new IgniteStringBuilder(17);
+ int date = (int) (timestamp / DateTimeUtils.MILLIS_PER_DAY);
+ int time = (int) (timestamp % DateTimeUtils.MILLIS_PER_DAY);
+
+ if (time < 0) {
+ --date;
+
+ time += (int) DateTimeUtils.MILLIS_PER_DAY;
+ }
+
+ buf.app(DateTimeUtils.unixDateToString(date)).app(' ');
+
+ unixTimeToString(buf, time, precision);
+
+ return buf.toString();
+ }
+
+ /**
+ * Helper for CAST({time} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimeToString(int time, int precision) {
+ IgniteStringBuilder buf = new IgniteStringBuilder(8);
Review Comment:
I guess default buffer size is '8' for precision '0'.
Should it be `8+ (precision>0) ? 1 + precision: 0 `?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1554534762
##########
modules/sql-engine/src/integrationTest/sql/types/time/time_parsing.test:
##########
@@ -25,5 +25,5 @@ SELECT '14:42:04.999'::TIME(3)::VARCHAR
query I
SELECT '14:42:04.999'::TIME(6)::VARCHAR
----
-14:42:04.999000
+14:42:04.999
Review Comment:
Precision isn't ignored, we just don't add trailing zeros now.
I copied the original test to make it more clear.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1554062007
##########
modules/sql-engine/src/integrationTest/sql/types/time/time_parsing.test:
##########
@@ -25,5 +25,5 @@ SELECT '14:42:04.999'::TIME(3)::VARCHAR
query I
SELECT '14:42:04.999'::TIME(6)::VARCHAR
----
-14:42:04.999000
+14:42:04.999
Review Comment:
Why does precision is ignored?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557319992
##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcClientTimeZoneTest.java:
##########
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.zone.ZoneRulesException;
+import java.util.Objects;
+import java.util.TimeZone;
+import org.apache.ignite.internal.jdbc.ConnectionProperties;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test checks the client time zone propagation from the jdbc client to the server node.
+ */
+@SuppressWarnings("CallToDriverManagerGetConnection")
+public class ItJdbcClientTimeZoneTest extends AbstractJdbcSelfTest {
+ private static final String TIMESTAMP_STR = "1970-01-01 00:00:00";
+
+ private ZoneId origin;
+
+ @BeforeAll
+ static void createTable() throws SQLException {
+ try (Statement stmt = conn.createStatement()) {
+ stmt.execute("CREATE TABLE test(id INT PRIMARY KEY, ts TIMESTAMP, ts_tz TIMESTAMP WITH LOCAL TIME ZONE)");
+ }
+ }
+
+ @BeforeEach
+ void saveTimeZoneAndClearTable() throws SQLException {
+ origin = TimeZone.getDefault().toZoneId();
+
+ stmt.execute("DELETE FROM test");
+ }
+
+ @AfterEach
+ void restoreTimezone() {
+ ZoneId current = TimeZone.getDefault().toZoneId();
+
+ if (!Objects.equals(origin, current)) {
+ TimeZone.setDefault(TimeZone.getTimeZone(origin));
+ }
+ }
+
+ /** Ensures that the default JVM time zone is passed to the server. */
+ @Test
+ public void jvmTimeZonePassedToServer() throws SQLException {
+ ZoneId serverTimezone = TimeZone.getTimeZone("GMT+1").toZoneId();
+
+ // Client time zone.
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT+02:00"));
+
+ withNewConnection(URL, stmt -> {
+ // Set server timezone.
+ TimeZone.setDefault(TimeZone.getTimeZone(serverTimezone));
+
+ stmt.executeUpdate(format("INSERT INTO test VALUES(0, '{}', '{}')", TIMESTAMP_STR, TIMESTAMP_STR));
+
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 00:00:00 GMT+02:00");
+ });
+
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT+03:00"));
+
+ withNewConnection(URL, stmt -> {
+ // Set server timezone.
+ TimeZone.setDefault(TimeZone.getTimeZone(serverTimezone));
+
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 01:00:00 GMT+03:00");
+ });
+ }
+
+ /**
+ * Ensures that session time zone can be changed using
+ * connection property {@link ConnectionProperties#setConnectionTimeZone(ZoneId)}.
+ */
+ @Test
+ public void timeZoneCanBeSetUsingProperty() throws SQLException {
+ String originTimeZone = TimeZone.getDefault().getID();
+
+ {
+ String timeZone = "GMT+02:00";
+
+ withNewConnection(URL + "?connectionTimeZone=" + timeZone, stmt -> {
+ stmt.executeUpdate(format("INSERT INTO test VALUES(0, '{}', '{}')", TIMESTAMP_STR, TIMESTAMP_STR));
+
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 00:00:00 " + timeZone);
+ });
+ }
+
+ {
+ String timeZone = "GMT+03:00";
+
+ withNewConnection(URL + "?connectionTimeZone=" + timeZone, stmt -> {
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 01:00:00 " + timeZone);
+ });
+ }
+
+ {
+ String timeZone = "invalid/timezone";
+
+ assertThrows(
+ ZoneRulesException.class,
Review Comment:
do we need to wrap such exception into appropriate sqlexception ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557420442
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteSqlFunctions.java:
##########
@@ -574,6 +575,75 @@ public static Long subtractTimeZoneOffset(long timestamp, TimeZone timeZone) {
return timestamp - offset;
}
+ /**
+ * Helper for CAST({timestamp} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimestampToString(long timestamp, int precision) {
Review Comment:
> is it critical that we append trailing zeros ?
Without removing trailing zeros current conversion
from TIMESTAMP to TIMESTAMP TZ fails in `TimestampString#normalize` method.
For example for string `2008-01-01 00:00:01.000000`
It removes all zeros and got `2008-01-01 00:00:01.` and then expects that after '.' will be at least one digit.
I don't think this is critical since we can implement our own TIMESTAMP to TIMESTAMP_TZ conversion.
> it made for consistency between different temporal tests conversion
From my point of view, yes, it makes the current behavior more consistent.
The following queries:
```
SELECT (TIMESTAMP '2008-01-01 00:00:01.001')::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP WITH LOCAL TIME ZONE::VARCHAR
SELECT (TIMESTAMP WITH LOCAL TIME ZONE '2008-01-01 00:00:01.001')::VARCHAR
```
Output the following result before this change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001000
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
After this change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557340765
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteSqlFunctions.java:
##########
@@ -574,6 +575,75 @@ public static Long subtractTimeZoneOffset(long timestamp, TimeZone timeZone) {
return timestamp - offset;
}
+ /**
+ * Helper for CAST({timestamp} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimestampToString(long timestamp, int precision) {
Review Comment:
is it critical that we append trailing zeros ? or it made for consistency between different temporal tests conversion ? what if we are using not modifying functions ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1554534848
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteSqlFunctions.java:
##########
@@ -574,6 +575,75 @@ public static Long subtractTimeZoneOffset(long timestamp, TimeZone timeZone) {
return timestamp - offset;
}
+ /**
+ * Helper for CAST({timestamp} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimestampToString(long timestamp, int precision) {
+ IgniteStringBuilder buf = new IgniteStringBuilder(17);
+ int date = (int) (timestamp / DateTimeUtils.MILLIS_PER_DAY);
+ int time = (int) (timestamp % DateTimeUtils.MILLIS_PER_DAY);
+
+ if (time < 0) {
+ --date;
+
+ time += (int) DateTimeUtils.MILLIS_PER_DAY;
+ }
+
+ buf.app(DateTimeUtils.unixDateToString(date)).app(' ');
+
+ unixTimeToString(buf, time, precision);
+
+ return buf.toString();
+ }
+
+ /**
+ * Helper for CAST({time} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimeToString(int time, int precision) {
+ IgniteStringBuilder buf = new IgniteStringBuilder(8);
Review Comment:
Done, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557420442
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteSqlFunctions.java:
##########
@@ -574,6 +575,75 @@ public static Long subtractTimeZoneOffset(long timestamp, TimeZone timeZone) {
return timestamp - offset;
}
+ /**
+ * Helper for CAST({timestamp} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing zeros.
+ */
+ public static String unixTimestampToString(long timestamp, int precision) {
Review Comment:
> is it critical that we append trailing zeros ?
Without removing trailing zeros current conversion
from TIMESTAMP to TIMESTAMP TZ fails in `TimestampString#normalize` method.
For example for string `2008-01-01 00:00:01.000000`
It removes all zeros and got `2008-01-01 00:00:01.` and then expects that after '.' will be at least one digit.
I don't think this is critical since we can implement our own TIMESTAMP to TIMESTAMP_TZ conversion.
> it made for consistency between different temporal tests conversion
From my point of view, yes, it makes the current behavior more consistent.
The following queries:
```
SELECT (TIMESTAMP '2008-01-01 00:00:01.001')::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP WITH LOCAL TIME ZONE::VARCHAR
SELECT (TIMESTAMP WITH LOCAL TIME ZONE '2008-01-01 00:00:01.001')::VARCHAR
```
Output the following result before the change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001000
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
After the change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557334659
##########
modules/sql-engine/src/integrationTest/sql/types/time/time_parsing.test:
##########
@@ -22,8 +22,8 @@ SELECT '14:42:04.999'::TIME(3)::VARCHAR
----
14:42:04.999
+# trailing zeros get truncated
query I
-SELECT '14:42:04.999'::TIME(6)::VARCHAR
+SELECT '14:42:04.000000'::TIME(6)::VARCHAR
Review Comment:
i don`t understand here, you rewrite valid test into different one ?
i suppose you just need to append something like : SELECT '14:42:04.999000'::TIME(6)::VARCHAR, wdyt ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557437164
##########
modules/sql-engine/src/integrationTest/sql/types/time/time_parsing.test:
##########
@@ -22,8 +22,8 @@ SELECT '14:42:04.999'::TIME(3)::VARCHAR
----
14:42:04.999
+# trailing zeros get truncated
query I
-SELECT '14:42:04.999'::TIME(6)::VARCHAR
+SELECT '14:42:04.000000'::TIME(6)::VARCHAR
Review Comment:
But in general I agree, I think the comment is enough, so I did as you suggested.
##########
modules/sql-engine/src/integrationTest/sql/types/time/time_parsing.test:
##########
@@ -22,8 +22,8 @@ SELECT '14:42:04.999'::TIME(3)::VARCHAR
----
14:42:04.999
+# trailing zeros get truncated
query I
-SELECT '14:42:04.999'::TIME(6)::VARCHAR
+SELECT '14:42:04.000000'::TIME(6)::VARCHAR
Review Comment:
But in general I agree, I think the comment is enough, so I did as you suggested, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557134219
##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc/ConnectionPropertiesImpl.java:
##########
@@ -124,11 +126,15 @@ private static String[] clientAuthValues() {
private final StringProperty password = new StringProperty("password",
"Password", null, null, false, null);
+ /** Client connection time zone ID. This property can be used by the client to change the time zone of the "session" on the server. */
+ private final StringProperty connectionTimeZone = new StringProperty("connectionTimeZone",
Review Comment:
why do we need this `connection` prefix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557810830
##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcClientTimeZoneTest.java:
##########
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc;
+
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.zone.ZoneRulesException;
+import java.util.Objects;
+import java.util.TimeZone;
+import org.apache.ignite.internal.jdbc.ConnectionProperties;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test checks the client time zone propagation from the jdbc client to the server node.
+ */
+@SuppressWarnings("CallToDriverManagerGetConnection")
+public class ItJdbcClientTimeZoneTest extends AbstractJdbcSelfTest {
+ private static final String TIMESTAMP_STR = "1970-01-01 00:00:00";
+
+ private ZoneId origin;
+
+ @BeforeAll
+ static void createTable() throws SQLException {
+ try (Statement stmt = conn.createStatement()) {
+ stmt.execute("CREATE TABLE test(id INT PRIMARY KEY, ts TIMESTAMP, ts_tz TIMESTAMP WITH LOCAL TIME ZONE)");
+ }
+ }
+
+ @BeforeEach
+ void saveTimeZoneAndClearTable() throws SQLException {
+ origin = TimeZone.getDefault().toZoneId();
+
+ stmt.execute("DELETE FROM test");
+ }
+
+ @AfterEach
+ void restoreTimezone() {
+ ZoneId current = TimeZone.getDefault().toZoneId();
+
+ if (!Objects.equals(origin, current)) {
+ TimeZone.setDefault(TimeZone.getTimeZone(origin));
+ }
+ }
+
+ /** Ensures that the default JVM time zone is passed to the server. */
+ @Test
+ public void jvmTimeZonePassedToServer() throws SQLException {
+ ZoneId serverTimezone = TimeZone.getTimeZone("GMT+1").toZoneId();
+
+ // Client time zone.
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT+02:00"));
+
+ withNewConnection(URL, stmt -> {
+ // Set server timezone.
+ TimeZone.setDefault(TimeZone.getTimeZone(serverTimezone));
+
+ stmt.executeUpdate(format("INSERT INTO test VALUES(0, '{}', '{}')", TIMESTAMP_STR, TIMESTAMP_STR));
+
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 00:00:00 GMT+02:00");
+ });
+
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT+03:00"));
+
+ withNewConnection(URL, stmt -> {
+ // Set server timezone.
+ TimeZone.setDefault(TimeZone.getTimeZone(serverTimezone));
+
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 01:00:00 GMT+03:00");
+ });
+ }
+
+ /**
+ * Ensures that session time zone can be changed using
+ * connection property {@link ConnectionProperties#setConnectionTimeZone(ZoneId)}.
+ */
+ @Test
+ public void timeZoneCanBeSetUsingProperty() throws SQLException {
+ String originTimeZone = TimeZone.getDefault().getID();
+
+ {
+ String timeZone = "GMT+02:00";
+
+ withNewConnection(URL + "?connectionTimeZone=" + timeZone, stmt -> {
+ stmt.executeUpdate(format("INSERT INTO test VALUES(0, '{}', '{}')", TIMESTAMP_STR, TIMESTAMP_STR));
+
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 00:00:00 " + timeZone);
+ });
+ }
+
+ {
+ String timeZone = "GMT+03:00";
+
+ withNewConnection(URL + "?connectionTimeZone=" + timeZone, stmt -> {
+ validateSingleRow("SELECT ts::VARCHAR, ts_tz::VARCHAR FROM test", stmt,
+ "1970-01-01 00:00:00", "1970-01-01 01:00:00 " + timeZone);
+ });
+ }
+
+ {
+ String timeZone = "invalid/timezone";
+
+ assertThrows(
+ ZoneRulesException.class,
Review Comment:
Thanks, I missed this one, wrapped in a standard jdbc SQLException (like other jdbc property validation errors).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-19274 Sql. Jdbc client time zone propagation [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern merged PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org