Class SessionZone

java.lang.Object
dev.frostlake.executor.SessionZone

public final class SessionZone extends Object
The zone the session's TIMEZONE parameter names, reachable from the value layer.

A TIMESTAMP_LTZ is an INSTANT, and the wall clock it shows is that instant read in the SESSION's zone — so the same stored value renders 2020-01-01 10:00:00 -0800 under America/Los_Angeles and 2020-01-01 18:00:00 Z under UTC. Reading and rendering one therefore needs the session's zone, and both happen deep inside static helpers that have no session to ask.

Held in a ThreadLocal and pinned for the statement, exactly as StatementClock pins the statement's instant and for the same reason: one engine serves many sessions, so this must not be a process-wide setting. The default is UTC, which is what the engine used everywhere before the parameter was read at all.

  • Method Details

    • current

      public static ZoneId current()
      The session's zone, or UTC when nothing is pinned.
    • pin

      public static ZoneId pin(Object zoneName)
      Pin this statement's zone, returning what was pinned before so the caller can restore it. An unusable or absent name leaves UTC rather than raising: the parameter is validated where it is SET, and a rendering path is the wrong place to discover a bad one.
    • restore

      public static void restore(ZoneId previous)
      Put back whatever pin(java.lang.Object) displaced; a null restores the unpinned state.