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

Aperta Adatta ai principianti
#1,591 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
86/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend, testing

Direzione di ricerca

Leggi arrow/compute/internal/kernels/rounding.go, concentrandoti su roundTimestampCalendar. Confronta i rami RoundUp per Year, Quarter e Month con il ramo Day. Aggiungi un test di regressione basato sulla riproduzione per i valori già sui confini del calendario, quindi esegui i test di arrotondamento pertinenti. Il lavoro è completato quando le opzioni predefinite preservano i timestamp allineati di Year, Quarter e Month e il comportamento esistente di arrotondamento per eccesso continua a superare i test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 🤖

Lingua principale
Assembly
Stelle
423
Fork
188
Merge medio
1g 7h
PR unite (30g)
164

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/arrow-go

Tutte le issue di apache/arrow-go

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.