Model time zone: which day CURRENT_DATE and the date of an instant mean
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
Start with core-spec/relational_semantics.md §10.2 and trace how the model schema and expression semantics define timezone-sensitive evaluation. Review core-spec/spec.md, core-spec/expression_language.md, and the proposed fixture and cases for deterministic compliance coverage. Done means the model zone behavior, unsupported-zone errors, compatibility without time_zone, and test expectations are specified consistently; the issue author already has a branch and offers to open a PR.
索引モデルが issue の本文から書いたものです。
説明
An Ossie model can declare a field as DateTimeTz, an instant (core-spec/spec.md, Data types). Turning an instant into a date or a clock reading needs a time zone, and so does CURRENT_DATE. The spec names no zone for either. Layer 1 promises that "expressions in an Ossie model evaluate identically on any conforming engine" (core-spec/spec_layers.md). Section 10.2 of core-spec/relational_semantics.md lists timezone-sensitive functions among the dialect differences the query interface inherits. For a field such as CAST(created_at AS DATE) the two statements pull apart: the expression is Layer 1, and its result depends on the zone of the engine.
The model author cannot name a zone in portable SQL. The expression language has no AT TIME ZONE and no timestamp literal with a zone (core-spec/expression_language.md, Date/Time Construction).
The instant 2026-11-06 03:00:00 UTC, which is 22:00 on November 5 in New York, as a date (checked 2026-11-10):
| Engine | Zone it uses | Expression | Date |
|---|---|---|---|
| DuckDB 2.0.0 | session TimeZone = UTC |
CAST(TIMESTAMPTZ '2026-11-06 03:00:00+00' AS DATE) |
2026-11-06 |
| DuckDB 2.0.0 | session TimeZone = America/New_York |
same | 2026-11-05 |
ClickHouse 26.9.5.2, clickhouse local |
server zone, TZ=UTC |
toDate(ts), ts a DateTime column with no zone parameter |
2026-11-06 |
ClickHouse 26.9.5.2, clickhouse local |
server zone, TZ=America/New_York |
same | 2026-11-05 |
By its documentation, BigQuery computes CURRENT_DATE in UTC unless the call names a zone. A Databricks SQL TIMESTAMP is an instant. Its documentation says the session time zone is applied whenever the value or a part of it is extracted.
A store in New York counts its days in its own zone, as its reports do. "Orders today" is the filter orders.order_day = CURRENT_DATE, where order_day is CAST(created_at AS DATE). On an engine in UTC, both sides are already the next day from 19:00 New York time (20:00 in summer). From then on the filter returns only the orders placed since 19:00. For a store east of UTC, after local midnight the filter also returns part of the previous day.
The zone of a store's dates is a property of its data, the same for every query against the model. That separates it from query-time parameters (#648), which change between queries. The problem exists in a model before any query is written, in a field like order_day above. A Layer 3 filter is "one Layer 1 boolean expression" (core-spec/wide_table_semantics.md, §3.4), so a model zone also fixes CURRENT_DATE in Layer 3 filters.
Proposal: an optional time_zone on the semantic model, an IANA name such as America/New_York. When it is set, every expression evaluated against the model uses that zone:
CURRENT_DATEandCURRENT_TIMEare counted in the model zone.CURRENT_TIMESTAMPis the current instant.- An instant is read as its wall-clock time in the model zone when converted to
Date,DateTimeorTime. The same holds inYEARtoSECOND, inEXTRACTandDATE_PARTwith any part, and inDATE_TRUNC.DATEDIFFandDATEADDfollow it with a part ofdayor coarser. - In the other direction, a
DateTimeorDatevalue compared with an instant is read in the model zone. ATIMESTAMP_NTZliteral is such a value. - A wall-clock time that a daylight saving change skips or repeats maps to an implementation-defined instant.
- An engine that cannot evaluate an expression in the model zone rejects the query with an error. It does not fall back to another zone. An engine rejects a model whose zone name it does not recognize.
Whether a value is an instant depends on its type in the engine, for example a timestamp with time zone. A timestamp column without a zone holds wall-clock values, read as local time in the model zone. Some sources store UTC readings in such a column. A way to declare that, for example datatype: DateTimeTz on the field, could follow separately.
Without time_zone, the zone stays implementation-defined, as today, so no existing model changes meaning. The change adds a sentence to Section 10.2 that a model zone fixes the timezone-sensitive functions.
One zone per model covers a model of one store. A model that combines stores in several zones would need a zone per dataset or per row. A dataset-level time_zone could come later without changing what the model-level one means.
The query compliance data (SCOTT) has only DATE columns, and CURRENT_* cannot be pinned to a fixed value. Deterministic cases need a fixture table with a DateTimeTz column. Its instants fall on both sides of a day boundary in the model zone, and one falls near a daylight saving change. Over it, with time_zone set: CAST(... AS DATE), DATE_TRUNC('month', ...), EXTRACT(HOUR FROM ...), DATEDIFF(day, ...), and a TIMESTAMP_NTZ literal compared with the column. CURRENT_DATE can be tested only through a relation such as CURRENT_DATE = CAST(CURRENT_TIMESTAMP AS DATE).
Two tools already keep a zone setting outside the core. The OrionBelt model in ossie-converters has settings.defaultTimezone, an IANA name used as a fallback zone for naive timestamps (orionbelt/src/ossie_orionbelt/schemas/obml-schema.json). dactopus-ossie-clickhouse reads the model zone from its vendor entry in the model's extensions. The #522 thread calls behavior defined only through extensions non-portable, so a model zone looks like a candidate for the core.
I have a branch with the schema field, the spec text and tests, and can open a PR if this direction looks right.
- 主要言語
- Python
- スター
- 2.7k
- フォーク
- 353
- 平均マージ
- 3日 19時間
- マージ済み PR(30日)
- 86
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/ossie のほかの issue
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
メンテナーはふだん 1 日以内に返信
-
validation: field reference resolution is case-insensitive but name uniqueness is case-sensitive対応中かも @MikeNitsenko が 6 日前に担当しました。 オープンneeds-triage
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
integration: media_player
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
home-assistant/core#193344 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
daniel-ospina/tortoise#13607 ·
メンテナーはふだん 1 日以内に返信
-
documentation priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 66/100
Robin-IA/Congressional-Letters-Dev#1347 ·
メンテナーはふだん 1 日以内に返信