[Variant] Support a time zone when serializing Variant timestamps to JSON
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with parquet-variant-json/src/to_json.rs, where instant timestamps currently use to_rfc3339, and parquet-variant-compute/src/to_json.rs, which calls that serializer without options. Trace how scalar and batch serialization handle nested Variant values, then inspect the timestamp formatting and timezone utilities mentioned in arrow-cast/src/display.rs and arrow_array::timezone::Tz. Done means both APIs accept a zone while keeping UTC as the default, and tests cover the requested timestamp cases and consistent JSON outputs.
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem or challenge?
While implementing Spark-compatible Variant functions in datafusion-variant, we need to serialize timestamp values using the SQL session time zone or an explicit to_json option. Arrow's scalar VariantToJson methods and batch variant_to_json kernel currently expose no time-zone option and serialize instant timestamps in UTC, including timestamps nested in arrays and objects.
For example, this was executed against Arrow 60.0.0:
use arrow::array::{ArrayRef, TimestampMicrosecondArray};
use parquet_variant_compute::{cast_to_variant, variant_to_json};
use parquet_variant_json::VariantToJson;
let input = TimestampMicrosecondArray::from(vec![Some(0)]).with_timezone("UTC");
let variant = cast_to_variant(&input)?;
let scalar = variant.value(0).to_json_string()?;
let batch = variant_to_json(&ArrayRef::from(variant))?;
assert_eq!(scalar, "\"1970-01-01T00:00:00+00:00\"");
assert_eq!(batch.value(0), scalar);
Both assertions pass. There is no parameter to request America/Los_Angeles, which should render the same instant as "1969-12-31T16:00:00-08:00" using Arrow's existing RFC 3339 formatting.
Describe the solution you'd like
Add time-zone-aware serialization options for the scalar and batch APIs, retaining UTC as the default for existing callers.
- Apply the chosen zone to
TimestampMicrosandTimestampNanos, including values nested in Variant arrays and objects. - Leave timestamps without a time zone, dates, and times unchanged.
- Resolve named-zone offsets for each instant, including daylight-saving transitions.
- Keep streaming JSON, JSON strings,
serde_json::Value, and batch results consistent.
The caller would resolve SQL session settings and options; Arrow would perform the serialization. Tests should cover UTC, fixed offsets, named zones across daylight-saving transitions, both timestamp precisions, nested values, and unchanged timestamp-without-time-zone values.
Describe alternatives you've considered
A downstream recursive serializer would duplicate Arrow's existing handling of Variant values. Rewriting JSON strings afterward loses the distinction between timestamp values and ordinary strings with the same contents.
Additional context
The regular arrow-json writer already honors a timestamp array's declared time zone through ArrayFormatter. With Arrow 60.0.0, epoch 0 in an array annotated with America/Los_Angeles produced "1969-12-31T16:00:00-08:00". Variant timestamps do not carry that display-zone annotation, so their serializer needs a caller-supplied zone. Arrow's existing arrow_array::timezone::Tz provides reusable timezone handling; the timestamp formatting helper itself is currently private.
Current main at 5746b443f7 still formats instant timestamps directly with to_rfc3339, and the batch kernel calls the same serializer without options.
Spark's Variant JSON writer passes the configured zone to VariantVal.toJson. Its JSON options use the explicit time-zone option or the supplied default. These Spark sources were inspected, not executed locally; matching Spark's other timestamp formatting choices is outside this request.
A search of open and closed Arrow issues and PRs found no matching request. Related work: #10102 concerns temporal casting semantics, while #11402 reduced JSON serialization allocations without adding a time-zone option. Spark's #59561 concerns additional string/display paths; its to_json path already passes the configured zone.
- 主要言語
- Rust
- スター
- 3.7k
- フォーク
- 1.5k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 183
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/arrow-rs のほかの issue
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
`RunArray::try_new` rejects run ends whose null buffer has no nulls対応中かも @Surajsuthar が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/arrow-rs#12427 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Variant] `variant_get` string and binary cast errors show Rust builder type names再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
メンテナーはふだん 1 日以内に返信
apache/arrow-rs の issue をすべて見る
似ている issue
-
area:ui effort:medium enhancement P7 source:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousオープンmaintainer-needed p2 remote triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug help wanted ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
userFRM/egui-charts#4605 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信