You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "PetarVasiljevic-DB (via GitHub)" <gi...@apache.org> on 2024/03/15 19:04:36 UTC

[PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

PetarVasiljevic-DB opened a new pull request, #45537:
URL: https://github.com/apache/spark/pull/45537

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   New config for enabling usage of calendar with spark local session time zone in getTimestamp and setTimestamp JDBC API calls.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   It turns out that the users will see same 'string values' of timestamps as they are in remote data source only if JVM time zone and spark local session time zone are equal. If users change JVM time zone (which is possible) or spark local session time zone, then they are not going to see same results. Therefore, when calling getTimestamp and setTimestamp, calendar with spark local sesssion time zone is passed.
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   Yes, users can enable feature by setting `spark.sql.useLocalSessionCalendar` to `true`
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Unit tests on H2 dialect
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   No
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL] Add getDatabaseCalendar method to the JdbcDialect [spark]

Posted by "milastdbx (via GitHub)" <gi...@apache.org>.
milastdbx commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1593776643


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala:
##########
@@ -500,7 +501,11 @@ object JdbcUtils extends Logging with SQLConfHelper {
 
     case TimestampType =>
       (rs: ResultSet, row: InternalRow, pos: Int) =>
-        val t = rs.getTimestamp(pos + 1)
+        val t = dialect.getDatabaseCalendar match {
+          case Some(cal) => rs.getTimestamp(pos + 1, cal)

Review Comment:
   Unforntunatelly it really depends on driver implementation whether they handle difference between TZ and NTZ in their getTimestamp/setTimestamp codepath



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1527703992


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala:
##########
@@ -487,7 +488,13 @@ object JdbcUtils extends Logging with SQLConfHelper {
 
     case TimestampType =>
       (rs: ResultSet, row: InternalRow, pos: Int) =>
-        val t = rs.getTimestamp(pos + 1)
+        val t = if (conf.useLocalSessionCalendar) {

Review Comment:
   let's not check the conf perf row
   ```
   if (conf.useLocalSessionCalendar) {
     (rs: ResultSet, row: InternalRow, pos: Int) => ...
   } else {
     (rs: ResultSet, row: InternalRow, pos: Int) => ...
   }
   ```



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala:
##########
@@ -604,10 +611,20 @@ object JdbcUtils extends Logging with SQLConfHelper {
     case TimestampType =>
       if (conf.datetimeJava8ApiEnabled) {
         (stmt: PreparedStatement, row: Row, pos: Int) =>
-          stmt.setTimestamp(pos + 1, toJavaTimestamp(instantToMicros(row.getAs[Instant](pos))))
+          if (conf.useLocalSessionCalendar) {

Review Comment:
   ditto



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "milastdbx (via GitHub)" <gi...@apache.org>.
milastdbx commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1544332756


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -3876,6 +3876,16 @@ object SQLConf {
     .booleanConf
     .createWithDefault(false)
 
+  val USE_LOCAL_SESSION_CALENDAR = buildConf("spark.sql.jdbc.useLocalSessionCalendar")

Review Comment:
   lets move this to be connector option.
   this way we can enable it per connector



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1527703368


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -3876,6 +3876,13 @@ object SQLConf {
     .booleanConf
     .createWithDefault(false)
 
+  val USE_LOCAL_SESSION_CALENDAR = buildConf("spark.sql.useLocalSessionCalendar")
+    .doc("If the configuration property is set to true, rs.getTimestamp and rs.setTimestamp" +
+      "API calls will pass calendar with spark local session time zone as the second argument")

Review Comment:
   let's provide more context here...



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1527703518


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -3876,6 +3876,13 @@ object SQLConf {
     .booleanConf
     .createWithDefault(false)
 
+  val USE_LOCAL_SESSION_CALENDAR = buildConf("spark.sql.useLocalSessionCalendar")
+    .doc("If the configuration property is set to true, rs.getTimestamp and rs.setTimestamp" +
+      "API calls will pass calendar with spark local session time zone as the second argument")

Review Comment:
   This doesn't even mention the JDBC data source.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL] Add getDatabaseCalendar method to the JdbcDialect [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1593536803


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala:
##########
@@ -500,7 +501,11 @@ object JdbcUtils extends Logging with SQLConfHelper {
 
     case TimestampType =>
       (rs: ResultSet, row: InternalRow, pos: Int) =>
-        val t = rs.getTimestamp(pos + 1)
+        val t = dialect.getDatabaseCalendar match {
+          case Some(cal) => rs.getTimestamp(pos + 1, cal)

Review Comment:
   shall we always call `get/setTimestamp` with a calendar instance of the session local timezone? We can add a config to restore the old behavior, instead of adding a new API in Dialect.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1527703135


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -3876,6 +3876,13 @@ object SQLConf {
     .booleanConf
     .createWithDefault(false)
 
+  val USE_LOCAL_SESSION_CALENDAR = buildConf("spark.sql.useLocalSessionCalendar")

Review Comment:
   ```suggestion
     val USE_LOCAL_SESSION_CALENDAR = buildConf("spark.sql.jdbc.useLocalSessionCalendar")
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #45537:
URL: https://github.com/apache/spark/pull/45537#issuecomment-2002768056

   cc @yaooqinn 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "PetarVasiljevic-DB (via GitHub)" <gi...@apache.org>.
PetarVasiljevic-DB commented on code in PR #45537:
URL: https://github.com/apache/spark/pull/45537#discussion_r1528528619


##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -3028,4 +3041,146 @@ class JDBCV2Suite extends QueryTest with SharedSparkSession with ExplainSuiteHel
     val explained = getNormalizedExplain(df, FormattedMode)
     assert(explained.contains("External engine query:"))
   }
+
+  test("Test timestamp scan roundtrip with calendar feature flag") {
+    // Test roundtrip with spark session time zone being equal to JVM time zone
+    withSQLConf(SQLConf.USE_LOCAL_SESSION_CALENDAR.key -> "true",
+      SQLConf.SESSION_LOCAL_TIMEZONE.key -> "America/Los_Angeles") {
+      withConnection { conn =>
+        conn.prepareStatement(
+            "CREATE TABLE \"test\".\"timestampstemp\" (timestampntz TIMESTAMP," +
+              " timestamptz TIMESTAMP WITH TIME ZONE)")
+          .executeUpdate()
+      }
+
+      sql("INSERT INTO h2.test.timestampstemp SELECT * FROM h2.test.timestamps")
+      val df = sql("SELECT * from h2.test.timestampstemp")
+      val displayedResults = df.showString(20, 20)
+
+      assert(df.collect().length == 3)
+
+      // assert that the values shown to user are same as the values stored in table
+      assert(displayedResults.contains("2022-03-03 02:00:00|2022-03-02 18:00:00"))
+      assert(displayedResults.contains("2022-03-02 02:00:00|2022-03-01 16:00:00"))
+      assert(displayedResults.contains("2022-03-01 02:00:00|2022-02-28 15:00:00"))
+
+      withConnection { conn =>
+        conn.prepareStatement("DROP TABLE \"test\".\"timestampstemp\"").executeUpdate()
+      }
+    }
+
+
+    // Test roundtrip with spark session time zone (EET, which is UTC+2)
+    // being different than JVM time zone
+    withSQLConf(SQLConf.USE_LOCAL_SESSION_CALENDAR.key -> "true",
+      SQLConf.SESSION_LOCAL_TIMEZONE.key -> "EET") {
+      withConnection { conn =>
+        conn.prepareStatement(
+            "CREATE TABLE \"test\".\"timestampstemp\" (timestampntz TIMESTAMP," +
+              " timestamptz TIMESTAMP WITH TIME ZONE)")
+          .executeUpdate()
+      }
+
+      sql("INSERT INTO h2.test.timestampstemp SELECT * FROM h2.test.timestamps")
+      val df = sql("SELECT * from h2.test.timestamps")
+      val displayedResults = df.showString(20, 20)
+
+      assert(df.collect().length == 3)
+      // assert that the values shown to user are same as the values stored in table
+      assert(displayedResults.contains("2022-03-03 02:00:00|2022-03-03 04:00:00"))
+      assert(displayedResults.contains("2022-03-02 02:00:00|2022-03-02 02:00:00"))
+      assert(displayedResults.contains("2022-03-01 02:00:00|2022-03-01 01:00:00"))
+
+      withConnection { conn =>
+        conn.prepareStatement("DROP TABLE \"test\".\"timestampstemp\"").executeUpdate()
+      }
+    }
+
+    // Same as first test but with different JVM time zone
+    withDefaultTimeZone(ZoneId.of("Europe/Belgrade")) {
+      withSQLConf(SQLConf.USE_LOCAL_SESSION_CALENDAR.key -> "true",
+        SQLConf.SESSION_LOCAL_TIMEZONE.key -> "America/Los_Angeles") {
+        withConnection { conn =>
+          conn.prepareStatement(
+              "CREATE TABLE \"test\".\"timestampstemp\" (timestampntz TIMESTAMP," +
+                " timestamptz TIMESTAMP WITH TIME ZONE)")
+            .executeUpdate()
+        }
+
+        sql("INSERT INTO h2.test.timestampstemp SELECT * FROM h2.test.timestamps")
+        val df = sql("SELECT * from h2.test.timestamps")
+        val displayedResults = df.showString(20, 20)
+
+        assert(df.collect().length == 3)
+        // assert that the values shown to user are same as the values stored in table
+        assert(displayedResults.contains("2022-03-03 02:00:00|2022-03-02 18:00:00"))
+        assert(displayedResults.contains("2022-03-02 02:00:00|2022-03-01 16:00:00"))
+        assert(displayedResults.contains("2022-03-01 02:00:00|2022-02-28 15:00:00"))
+
+        withConnection { conn =>
+          conn.prepareStatement("DROP TABLE \"test\".\"timestampstemp\"").executeUpdate()
+        }
+      }
+    }
+  }
+
+  test("Test timestamp filtering with calendar feature flag") {
+    // Test timestamp filter with spark session time zone being equal to JVM time zone
+    withSQLConf(SQLConf.USE_LOCAL_SESSION_CALENDAR.key -> "true",
+      SQLConf.SESSION_LOCAL_TIMEZONE.key -> "America/Los_Angeles") {
+      val df = sql("SELECT * FROM h2.test.timestamps where timestampntz = '2022-03-03 02:00:00'")
+      val displayedResults = df.showString(20, 20)
+
+      assert(df.collect().length == 1)
+      assert(displayedResults.contains("2022-03-03 02:00:00|2022-03-02 18:00:00"))
+    }
+
+    // Test timestamp filter with spark session time zone (EET, which is UTC+2)
+    // being different than JVM time zone
+    withSQLConf(SQLConf.USE_LOCAL_SESSION_CALENDAR.key -> "true",
+      SQLConf.SESSION_LOCAL_TIMEZONE.key -> "EET") {
+
+      // value pushed down will be "2022-02-02 16:00:00" because
+      // JVM time zone is America/Los_Angeles
+      val df = sql("SELECT * FROM h2.test.timestamps " +
+        "where timestamptz = '2022-03-02 02:00:00+02:00'")
+      val df2 = sql("SELECT * FROM h2.test.timestamps " +
+        "where timestamptz = '2022-03-02 04:00:00+04:00'")
+
+      val displayedResults = df.showString(20, 20)
+      val displayedResults2 = df.showString(20, 20)
+
+      // Both queries have to return same result
+      assert(df.collect().length == 1)
+      assert(df2.collect().length == 1)
+      assert(displayedResults.contains("2022-03-02 02:00:00|2022-03-02 02:00:00"))
+      assert(displayedResults2.contains("2022-03-02 02:00:00|2022-03-02 02:00:00"))
+    }
+
+    // Similar to the previous test but with JVM time zone changed
+    withDefaultTimeZone(ZoneId.of("Europe/Belgrade")) {
+      withSQLConf(SQLConf.USE_LOCAL_SESSION_CALENDAR.key -> "true",
+        SQLConf.SESSION_LOCAL_TIMEZONE.key -> "America/Los_Angeles") {
+        // h2 driver node is still in America/Los_Angeles even though JVM time zone is changed.
+        // Therefore, in order to get same result set as in first test case, the value that
+        // is pushed down should be "2022-02-02 16:00:00". Since local JVM time zone is
+        // Europe/Belgrade, in filter we put is "2022-03-01 17:00:00+02:00". This will be
+        // equal to "2022-03-01 16:00:00+01:00" and only "2022-03-01 16:00:00" will be
+        // pushed down
+        val df = sql("SELECT * FROM h2.test.timestamps " +

Review Comment:
   Potential solution of this problem is not in the scope of this PR. 



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn commented on PR #45537:
URL: https://github.com/apache/spark/pull/45537#issuecomment-2002837892

   Can we elaborate a bit more about the issue here? I'm not sure whether we see a wrong string representation of a timestamp or we get/set a wrong timestamp


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "PetarVasiljevic-DB (via GitHub)" <gi...@apache.org>.
PetarVasiljevic-DB commented on PR #45537:
URL: https://github.com/apache/spark/pull/45537#issuecomment-2003957689

   > Can we elaborate a bit more about the issue here? I'm not sure whether we see a wrong string representation of a timestamp or we get/set a wrong timestamp
   
   When I mention timestamp I mean timestamp without time zone information. Let's say JVM time zone and spark local session time zone is PST. If timezone literal in remote data source is for example "2020-02-02 02:00:00" and you read it via getTimestamp JDBC API call, it will use default calendar and load some value. This read timestamp will be "2020-02-02 02:00:00-08" and when shown to user (via df.show() for example) it will be shown as "2020-02-02 02:00:00", the same as it is data source. 
   Now, let's say JVM time zone is PST, but spark local session time zone is UTC. Again, same timestamp will be in data source, and when read it will be "2020-02-02 02:00:00-08", but it is equal to "2020-02-02 10:00:00+00" as therefore, "2020-02-02 10:00:00" will be shown to user, which is not the same as in data source.
   
   Keep in mind that we map NTZ timestamp from data source to TimestampType in spark (which has time zone information) and because of this, we are also reading/writing wrong values (different epochs_), but it is not the scope of this PR. In this PR, it is only fixed what user sees.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-47424][SQL]Add feature flag to enable spark local session time zone calendar in JDBC API calls [spark]

Posted by "PetarVasiljevic-DB (via GitHub)" <gi...@apache.org>.
PetarVasiljevic-DB commented on PR #45537:
URL: https://github.com/apache/spark/pull/45537#issuecomment-2003966130

   > @PetarVasiljevic-DB You say about JVM time zone in PR's description, but all tests run in the same default JVM time zone. Could you, please, try to change it via `withDefaultTimeZone()`
   
   Done, please note my comment on change.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org