| 483 | } |
| 484 | |
| 485 | func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool, h *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet { |
| 486 | span, ctx := opentracing.StartSpanFromContext(ctx, "parquetQuerierWithFallback.Select") |
| 487 | defer span.Finish() |
| 488 | |
| 489 | newMatchers, shardInfo, err := querysharding.ExtractShardingInfo(matchers) |
| 490 | if err != nil { |
| 491 | return storage.ErrSeriesSet(err) |
| 492 | } |
| 493 | |
| 494 | hints := storage.SelectHints{ |
| 495 | Start: q.minT, |
| 496 | End: q.maxT, |
| 497 | } |
| 498 | |
| 499 | mint, maxt, limit := q.minT, q.maxT, 0 |
| 500 | if h != nil { |
| 501 | // let copy the hints here as we wanna potentially modify it |
| 502 | hints = *h |
| 503 | mint, maxt, limit = hints.Start, hints.End, hints.Limit |
| 504 | } |
| 505 | |
| 506 | maxt = q.adjustMaxT(maxt) |
| 507 | hints.End = maxt |
| 508 | |
| 509 | if maxt < mint { |
| 510 | return storage.EmptySeriesSet() |
| 511 | } |
| 512 | |
| 513 | remaining, parquet, err := q.getBlocks(ctx, mint, maxt, matchers) |
| 514 | defer q.incrementOpsMetric("Select", remaining, parquet) |
| 515 | |
| 516 | if err != nil { |
| 517 | return storage.ErrSeriesSet(err) |
| 518 | } |
| 519 | |
| 520 | if len(remaining) > 0 && q.fallbackDisabled { |
| 521 | err = parquetConsistencyCheckError(remaining) |
| 522 | return storage.ErrSeriesSet(err) |
| 523 | } |
| 524 | |
| 525 | // Lets sort the series to merge |
| 526 | if len(parquet) > 0 && len(remaining) > 0 { |
| 527 | sortSeries = true |
| 528 | } |
| 529 | |
| 530 | // Reset projection hints if: |
| 531 | // - there are mixed blocks (both parquet and non-parquet) |
| 532 | // - not all parquet blocks have hash column (version < 2) |
| 533 | if q.honorProjectionHints { |
| 534 | if len(remaining) > 0 || !allParquetBlocksHaveHashColumn(parquet) { |
| 535 | hints.ProjectionLabels = nil |
| 536 | hints.ProjectionInclude = false |
| 537 | } |
| 538 | if hints.ProjectionInclude && !slices.Contains(hints.ProjectionLabels, schema.SeriesHashColumn) { |
| 539 | // Series hash column is always required for projection unless duplicate label check is disabled. |
| 540 | hints.ProjectionLabels = append(hints.ProjectionLabels, schema.SeriesHashColumn) |
| 541 | |
| 542 | } |