Timezones Across a Global Product

timestamptz does not store a timezone

This is the sentence that unlocks everything else, and almost every timezone bug in an enterprise traces back to not believing it. A timestamptz column stores an int64 count of microseconds since the Unix epoch and nothing else. There is no zone attached to the value, no per-row offset, nowhere for "Asia/Kolkata" to live. The "tz" in the type name is a semantic flag asserting "this integer is a real point on the global timeline" — in Parquet it is literally the boolean isAdjustedToUTC = true on the logical type.

Iceberg typeSpark typePhysicallyMeansComparable across regions?
timestamptzTIMESTAMP (a.k.a. TIMESTAMP_LTZ, the default)int64 µs since epoch, UTCan instant — one moment, one value, worldwideYes — direct integer comparison
timestampTIMESTAMP_NTZint64 µs of packed wall-clock fieldsa calendar reading — "09:00 on the 29th", somewhere unstatedNo — meaningless without a zone
dateDATEint32 days since epoch, no zonea calendar dayNo

So a timestamptz is already timezone-normalised by construction. There is nothing to convert at rest, and no conversion happens on write beyond parsing the input. The only conversion in the whole system is at read: turning that integer back into the string 2026-08-29 14:03:11 for a human, which applies spark.sql.session.timeZone (or the browser's zone, or the user's profile setting). Two analysts running the identical query against the identical bytes see different strings — and that is correct behaviour, not a bug. The bytes never moved.

The end-to-end contract: convert at the edges, never in the middle

What makes this work "globally across the product" is not a clever type choice in one table — it's that the same instant crosses six systems without anyone touching it. The conversions live in exactly two places, both at the perimeter.

One conversion in, one conversion out — a UTC-only interior
One conversion in, one conversion out — a UTC-only interior
  1. The wire format is unambiguous, and rejected if it isn't. APIs accept and emit RFC 3339 with an offset (2026-08-29T14:03:11+05:30) or raw epoch millis. A naked 2026-08-29 14:03:11 is rejected at validation, because that string is undecidable — a client in Tokyo and one in Berlin mean two instants nine hours apart by it. This single rule kills more production incidents than any other item on this list.
  2. Normalise once, at the boundary. The API layer parses the offset and immediately produces an instant. From there the value crosses the message bus (epoch millis), the OLTP store (Postgres timestamptz — never bare timestamp), CDC, and the lake (Iceberg timestamptz) with zero further conversion. Every extra conversion hop is a place to double-apply an offset, which is the classic "our latencies are 5.5 hours" bug.
  3. Pin the session timezone in cluster defaults.spark.sql.session.timeZone=UTC, set once in the cluster/warehouse config, not per job and not per notebook. Skip this and your pipeline is non-deterministic in a way no code review catches: run it from an IST laptop and days(order_ts) buckets rows differently than the UTC scheduler does. Same code, same data, different numbers, nobody deployed anything. Trino has the equivalent knob; so does the JVM (-Duser.timezone=UTC) and the container (TZ=UTC) — set all three, because whichever you forget is the one that leaks.
  4. Convert back as late as possible. The BI tool, the UI, or the report renderer applies the viewer's zone at the final step. The zone comes from the user's profile (an IANA id they chose), falling back to the browser's — never from the server's locale, which is an accident of where the pod got scheduled.
WireRFC 3339 + offset
Busepoch millis (UTC)
OLTPtimestamptz
Laketimestamptz
Computesession tz = UTC
Displayuser profile IANA zone

Which type for which scenario

"Always UTC" is the right slogan for 90% of columns and actively wrong for the rest. The deciding question is never "where did this come from" — it's "if the world's timezone rules changed tomorrow, should this value's meaning change?" For an instant, no: the moment already happened, it's fixed. For civil time, yes: 09:00 local means 09:00 local under the new rules too.

ScenarioStore asWhy
Order placed, click, log line, payment captured, row updated — anything that happenedtimestamptzIt's an instant. It has a single true position on the global timeline and must sort against events from every other region.
Date of birth, contract effective date, invoice date, public holidaydateThere is no instant here at all. Attaching a time and a zone invents precision that doesn't exist and creates off-by-one-day bugs at every render.
"The store opens at 09:00 local", SLA business hours, cron-style recurring schedulestime/timestamp (NTZ) + IANA zone id columnIt must stay 09:00 after a DST transition or a national rule change. Freeze it to an instant and it silently drifts an hour twice a year.
A meeting or a job scheduled for a future local time, months outtimestamp (NTZ) + zone id, instant derived on readGovernments change DST law with weeks of notice (Brazil abolished it in 2019, Mexico in 2022, Iran in 2022, Lebanon shifted mid-2023). The instant you computed last year is now wrong; the local time plus the zone id is still right and just re-resolves.
"Revenue for the Japanese business day"timestamptz (truth) + a materialised local_date DATE column (convenience)Covered in TZ.4 — the instant stays authoritative, the local day is a derived denormalisation you partition and filter on.
Historical/legacy data whose original zone was never recordedtimestamp (NTZ), with the assumed zone documented in table propertiesDo not guess an offset and promote it to timestamptz — that launders an unknown into a false certainty that nobody downstream can detect or undo.

The partitioning consequence, and the pruning trap

Here is where the Read metadata.json straight, in Go section's callout becomes an actual data bug. days(order_ts) on a timestamptz truncates in UTC, because that's the only zone the value knows about. So a Tokyo business day (UTC+9) straddles two UTC partitions: an order placed at 08:00 JST on the 29th lands in the 2026-08-28 partition. Every per-day count for the JP region is wrong by nine hours' worth of orders at both ends, and it will reconcile against nothing.

There are two clean resolutions and you pick per table, based on who asks the questions of it:

Global product · UTC days

Accept UTC-truncated partitions. Analysts filter on instant ranges, not day equality:

WHERE order_ts >= TIMESTAMP '2026-08-29 00:00:00+09:00'
  AND order_ts <  TIMESTAMP '2026-08-30 00:00:00+09:00'

Iceberg prunes this correctly against UTC day partitions — the range simply touches two of them. Cheapest option, no extra columns, and the instant stays the only source of truth. Right default when the primary consumers are global (finance close in UTC, ops dashboards, ML features).

Regional reporting · local business day

Materialise the derived columns at write time and partition on them:

ALTER TABLE hms.db.orders
  ADD COLUMN order_local_date DATE,
  ADD COLUMN order_tz STRING;

ALTER TABLE hms.db.orders
  ADD PARTITION FIELD region;
-- then: partition by (region, order_local_date)

Right when every question is "per store, per local day" — retail, logistics, regional P&L. The instant column stays authoritative; the local date is denormalised convenience, never the reverse.

DST, offsets, and the other sharp edges

  • Not a bijection: Local wall-clock time → instant is neither injective nor total. On spring-forward, 02:30 simply does not exist; on fall-back, 01:30 happens twice. Any code path that stores local time and converts later must decide what to do with both cases — most libraries silently pick one, and "duration" arithmetic across that boundary produces negative latencies. Storing the instant sidesteps this entirely, which is the strongest single argument for the convention.
  • Not whole hours: Offsets are not all hour-aligned: India is +05:30, Nepal +05:45, the Chatham Islands +12:45. Anything that assumes an integer number of hours — a hand-rolled hours(ts) % 24, a hard-coded offset table — is wrong for hundreds of millions of users.
  • Not stable: The IANA tzdata database is amended several times a year. A pinned container image with a two-year-old tzdata will resolve future local times incorrectly, and nothing will error. If you store future civil time, tzdata is a dependency you must patch, not a static file.
  • Safely ignorable: Leap seconds. Unix time by definition has 86,400 seconds per day and repeats or smears the leap; every mainstream engine and cloud clock follows suit. Unless you are doing sub-second scientific timing, this is not your problem and you should not build for it.

How an enterprise actually makes it stick

The convention is easy; the enforcement is the engineering. A rule that lives in a wiki page is a rule that half your services violate within two quarters. What actually holds the line:

  1. One shared time library, and no direct clock access. A single internal module exposes Now(), parsing, and formatting; local clock APIs (time.Now() in unreviewed code, datetime.now() without a tz, new Date() string parsing) are lint-banned. This also buys you injectable clocks, which is what makes time-dependent tests deterministic.
  2. Schema review that treats a bare timestamp as a defect. A CI check over migrations and Iceberg DDL: any NTZ column must ship with a sibling zone-id column and a comment explaining why it's civil time. Default-deny, explicit-allow — the same shape as a security policy, because the failure mode is just as silent.
  3. Config, not convention, for session timezone.spark.sql.session.timeZone=UTC, TZ=UTC, and -Duser.timezone=UTC baked into base images and warehouse defaults, so a developer would have to actively override to get it wrong. Then set the developer laptop's session tz to something deliberately awkward (Pacific/Chatham) in test environments, so zone-sensitive code fails locally instead of in production.
  4. Contract tests at every boundary. One test per service that round-trips an instant through the full path — client → API → bus → store → lake → render — and asserts the integer is unchanged. Double-conversion bugs are invisible to unit tests and obvious to this one.
  5. Name the columns so the type is obvious.order_ts (instant), order_local_date (derived civil), opens_at_local + store_tz (civil + rule). A reader should not have to open DESCRIBE to know which semantics they're getting — and per the Read metadata.json straight, in Go section, the DDL you wrote may not be the type you got.