CeilTemporal moves values already on a Year/Quarter/Month boundary to the next period

オープン 初心者向け
#1,591 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
backend, testing

調査の方向性

arrow/compute/internal/kernels/rounding.goを読み、roundTimestampCalendarに注目してください。Year、Quarter、MonthのRoundUp分岐をDay分岐と比較してください。すでに暦上の境界にある値について、再現例に基づく回帰テストを追加し、該当する丸めテストを実行してください。完了条件は、デフォルトオプションで境界に揃ったYear、Quarter、Monthのタイムスタンプが保持され、既存の切り上げ動作も引き続きテストに合格することです。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug, including details regarding any error messages, version, and platform.

CeilTemporal with unit Year, Quarter or Month moves a value that is already on a period boundary to the next period. This happens with the default options (CeilIsStrictlyGreater: false). v18.8.0 returns the input unchanged. Day is not affected.

Version: v18.9.0. Regressed in 6542b630f84dda25715f6238027cc1eed9d114c6 (#1127).

Repro:

func TestCeilAlignedCalendar(t *testing.T) {
	mem := memory.NewGoAllocator()
	in, _, err := array.FromJSON(mem, &arrow.TimestampType{Unit: arrow.Second},
		strings.NewReader(`["1970-01-01T00:00:00", "2021-01-01T00:00:00"]`))
	if err != nil {
		t.Fatal(err)
	}
	defer in.Release()
	for _, unit := range []compute.RoundTemporalUnit{compute.RoundTemporalYear, compute.RoundTemporalQuarter, compute.RoundTemporalMonth, compute.RoundTemporalDay} {
		res, err := compute.CeilTemporal(context.Background(), compute.RoundTemporalOptions{Multiple: 1, Unit: unit}, compute.NewDatum(in))
		if err != nil {
			t.Fatal(err)
		}
		out := res.(*compute.ArrayDatum).MakeArray()
		if !array.Equal(in, out) {
			t.Errorf("unit=%d: in=%v out=%v", unit, in, out)
		}
		out.Release()
		res.Release()
	}
}

Output on v18.9.0 (unit 0 = Year, 1 = Quarter, 2 = Month):

--- FAIL: TestCeilAlignedCalendar (0.00s)
    unit=0: in=[0 1609459200] out=[31536000 1640995200]
    unit=1: in=[0 1609459200] out=[7776000 1617235200]
    unit=2: in=[0 1609459200] out=[2678400 1612137600]

The test passes on the parent of 6542b63 (72e9a56).

Cause: in arrow/compute/internal/kernels/rounding.go, roundTimestampCalendar, the RoundUp branches for Year, Quarter and Month always add multiple. Before #1127 they had the guard if opts.CeilIsStrictlyGreater || !t.Equal(periodStart). The Day branch still has it.

Component(s)

Go


beep boop, a clanker found this and wrote it up 🤖

主要言語
Assembly
スター
423
フォーク
188
平均マージ
1日 7時間
マージ済み PR(30日)
164

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/arrow-go のほかの issue

apache/arrow-go の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。