diff --git a/weed/mq/logstore/compaction_test.go b/weed/mq/logstore/compaction_test.go index 96b3d3a4ae..3b45ddec5b 100644 --- a/weed/mq/logstore/compaction_test.go +++ b/weed/mq/logstore/compaction_test.go @@ -434,3 +434,23 @@ func TestParquetReadResumesInsideAnEarlierFile(t *testing.T) { t.Errorf("stopping at 8s read %v, want %v", got, want) } } + +// The stop time is inclusive, as for log files: a row at it is read, and so is a +// file whose first row is at it. +func TestParquetReadIncludesARowAtTheStopTime(t *testing.T) { + f, client := newCompactionFiler(t) + f.putTopicConf(t) + base := time.Date(2026, 11, 30, 10, 0, 0, 0, time.UTC) + at := func(sec int) int64 { return base.Add(time.Duration(sec) * time.Second).UnixNano() } + f.putLogFile(t, base, 0, at(1), at(5), at(9)) + compactSchemaless(t, client) + f.removeLogFiles() + read := GenParquetReadFunc(client, compactionTopic, compactionPartition) + + if got, want := readParquetTimestamps(t, read, 1, at(5)), []int64{at(1), at(5)}; !slices.Equal(got, want) { + t.Errorf("stopping at 5s read %v, want %v", got, want) + } + if got, want := readParquetTimestamps(t, read, 1, at(1)), []int64{at(1)}; !slices.Equal(got, want) { + t.Errorf("stopping at the file's first row read %v, want %v", got, want) + } +} diff --git a/weed/mq/logstore/read_parquet_to_log.go b/weed/mq/logstore/read_parquet_to_log.go index 09ebbae7e3..8dac6e014b 100644 --- a/weed/mq/logstore/read_parquet_to_log.go +++ b/weed/mq/logstore/read_parquet_to_log.go @@ -135,7 +135,7 @@ func GenParquetReadFunc(filerClient filer_pb.FilerClient, t topic.Topic, p topic } // rows of windows flushed across a reload are not in time order tsNs := recordValue.Fields[SW_COLUMN_NAME_TS].GetInt64Value() - if tsNs <= starTsNs || (stopTsNs != 0 && tsNs >= stopTsNs) { + if tsNs <= starTsNs || (stopTsNs != 0 && tsNs > stopTsNs) { continue } @@ -208,7 +208,7 @@ func GenParquetReadFunc(filerClient filer_pb.FilerClient, t topic.Topic, p topic return nil } - if stopTsNs != 0 && stopTsNs <= minTsNs { + if stopTsNs != 0 && stopTsNs < minTsNs { return nil }