mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
MIN and MAX of _ts without column statistics were computed from file names, which are only the start second of a file's first source log: MIN rounded down to that second and MAX was the start of the latest file rather than its last row. Each file's stats already carry ts_min and ts_max as MinTimestampNs and MaxTimestampNs, so those are used when set, and names only for files that record no range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
package engine
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/mq/topic"
|
|
)
|
|
|
|
// A file's name is the start second of its first source log; MIN and MAX of _ts
|
|
// come from the timestamp range the file records, and from names only without one.
|
|
func TestSystemColumnTimestampRangePrefersFileStats(t *testing.T) {
|
|
base := time.Date(2026, 11, 30, 10, 0, 0, 0, time.UTC)
|
|
stats := map[string][]*ParquetFileStats{
|
|
"p0": {
|
|
{FileName: topic.LogFileName(base, 0) + ".parquet", MinTimestampNs: base.Add(500 * time.Millisecond).UnixNano(), MaxTimestampNs: base.Add(9 * time.Second).UnixNano()},
|
|
{FileName: topic.LogFileName(base.Add(5*time.Second), 4) + ".parquet"},
|
|
},
|
|
}
|
|
e := &SQLEngine{}
|
|
if got, want := e.getSystemColumnGlobalMin(SW_COLUMN_NAME_TIMESTAMP, stats), base.Add(500*time.Millisecond).UnixNano(); got != want {
|
|
t.Errorf("min %v, want %v", got, want)
|
|
}
|
|
if got, want := e.getSystemColumnGlobalMax(SW_COLUMN_NAME_TIMESTAMP, stats), base.Add(9*time.Second).UnixNano(); got != want {
|
|
t.Errorf("max %v, want %v", got, want)
|
|
}
|
|
|
|
stats["p0"] = stats["p0"][1:]
|
|
if got, want := e.getSystemColumnGlobalMax(SW_COLUMN_NAME_TIMESTAMP, stats), base.Add(5*time.Second).UnixNano(); got != want {
|
|
t.Errorf("max without stats %v, want the name's %v", got, want)
|
|
}
|
|
}
|