Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-42516

Non-captured session time zone in view creation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.3.3, 3.4.0
    • 3.3.3, 3.4.0
    • SQL
    • None

    Description

      The session time zone config is captured only when it is set explicitly but if it is not the view is instantiated with the current settings. That's might confuse users since query results depends on explicit SQL config settings while creating a view.

      The example below portraits the issue:

      val viewName = "v1_capture_test"
      withView(viewName) {
        assert(get.sessionLocalTimeZone === "America/Los_Angeles")
        createView(viewName,
          """select hour(ts) as H from (
            |  select cast('2022-01-01T00:00:00.000 America/Los_Angeles' as timestamp) as ts
            |)""".stripMargin, Seq("H"))
        withDefaultTimeZone(java.time.ZoneId.of("UTC-09:00")) {
          withSQLConf(SESSION_LOCAL_TIMEZONE.key -> "UTC-10:00") {
            sql(s"select H from $viewName").show(false)
          }
        }
      } 

      It is expected to output:

      +---+
      |H  |
      +---+
      |0  |
      +---+ 

      but actual output is:

      +---+
      |H  |
      +---+
      |8  |
      +---+ 

      Attachments

        Activity

          People

            maxgekk Max Gekk
            maxgekk Max Gekk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: