MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestSelectProjectionHints

Function TestSelectProjectionHints

pkg/querier/parquet_queryable_test.go:636–853  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

634}
635
636func TestSelectProjectionHints(t *testing.T) {
637 block1 := ulid.MustNew(1, nil)
638 block2 := ulid.MustNew(2, nil)
639 now := time.Now()
640
641 tests := map[string]struct {
642 minT int64
643 maxT int64
644 honorProjectionHints bool // Whether to honor projection hints
645 hasRemainingBlocks bool // Whether there are non-parquet (TSDB) blocks
646 parquetBlockVersion int // Version of parquet blocks (1 or 2)
647 mixedVersions bool // If true, block1 is v1, block2 is v2
648 inputProjectionLabels []string
649 inputProjectionInclude bool // Input ProjectionInclude value
650 expectedProjectionLabels []string // nil means projection disabled
651 expectedProjectionInclude bool
652 }{
653 "projection enabled: honor enabled, all parquet blocks v2, no remaining blocks": {
654 minT: util.TimeToMillis(now.Add(-10 * time.Hour)),
655 maxT: util.TimeToMillis(now.Add(-5 * time.Hour)),
656 honorProjectionHints: true,
657 hasRemainingBlocks: false,
658 parquetBlockVersion: parquet.ParquetConverterMarkVersion2, // Version 2 has hash column
659 inputProjectionLabels: []string{"__name__", "job"},
660 inputProjectionInclude: true,
661 expectedProjectionLabels: []string{"__name__", "job", schema.SeriesHashColumn},
662 expectedProjectionInclude: true,
663 },
664 "projection disabled: honor enabled, mixed blocks (parquet + TSDB)": {
665 minT: util.TimeToMillis(now.Add(-10 * time.Hour)),
666 maxT: util.TimeToMillis(now.Add(-5 * time.Hour)),
667 honorProjectionHints: true,
668 hasRemainingBlocks: true, // Mixed blocks
669 parquetBlockVersion: parquet.ParquetConverterMarkVersion2,
670 inputProjectionLabels: []string{"__name__", "job"},
671 inputProjectionInclude: true,
672 expectedProjectionLabels: nil, // Reset
673 expectedProjectionInclude: false,
674 },
675 "projection disabled: ProjectionInclude is false": {
676 minT: util.TimeToMillis(now.Add(-10 * time.Hour)),
677 maxT: util.TimeToMillis(now.Add(-5 * time.Hour)),
678 honorProjectionHints: true,
679 hasRemainingBlocks: false,
680 parquetBlockVersion: parquet.ParquetConverterMarkVersion2,
681 inputProjectionLabels: []string{"job"},
682 inputProjectionInclude: false,
683 expectedProjectionLabels: []string{"job"}, // Labels remain unchanged when ProjectionInclude is false
684 expectedProjectionInclude: false,
685 },
686 "projection disabled: honor enabled, parquet blocks version 1 (no hash column)": {
687 minT: util.TimeToMillis(now.Add(-10 * time.Hour)),
688 maxT: util.TimeToMillis(now.Add(-5 * time.Hour)),
689 honorProjectionHints: true,
690 hasRemainingBlocks: false,
691 parquetBlockVersion: parquet.ParquetConverterMarkVersion1, // Version 1 doesn't have hash column
692 inputProjectionLabels: []string{"__name__", "job"},
693 inputProjectionInclude: true,

Callers

nothing calls this directly

Calls 7

SelectMethod · 0.95
TimeToMillisFunction · 0.92
defaultOverridesFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected