Skip to content

[Parquet] Support querying sharded parquet files #7174

Closed

Description

@yeya24

Is your feature request related to a problem? Please describe.
The underlying parquet library we are using supports sharded parquet files recently. Instead of a single TSDB block converted to a single parquet file, now it supports converting 1 TSDB block to multiple sharded parquet files for better conversion performance.

Today, existing parquet reader only supports 1 shard and we hardcoded it. In order to support querying sharded parquet files, we need to avoid hardcoding the shard and try to read the block total shard size somewhere.

Reference:

Describe the solution you'd like
A clear and concise description of what you want to happen.

Activity

  1. added
    storage/blocks
    on Dec 26, 2025
  2. added and removed
    storage/blocks
    on Dec 26, 2025
  3. sandy2008 commented on Oct 28, 2026

    @sandy2008
    Contributor

    This was implemented by #7610, which is in the 1.22 release candidates: the querier now reads each block's Parquet shard count and opens every shard (

    // Calculate total number of shards across all blocks
    totalShards := 0
    for _, block := range blocks {
    numShards := 1 // Default to 1 shard for backward compatibility
    if block.Parquet != nil && block.Parquet.Shards > 0 {
    numShards = block.Parquet.Shards
    }
    totalShards += numShards
    }
    shards := make([]parquet_storage.ParquetShard, totalShards)
    errGroup := &errgroup.Group{}
    span, ctx := opentracing.StartSpanFromContext(ctx, "parquetQuerierWithFallback.OpenShards")
    defer span.Finish()
    shardIdx := 0
    for _, block := range blocks {
    numShards := 1 // Default to 1 shard for backward compatibility
    if block.Parquet != nil && block.Parquet.Shards > 0 {
    numShards = block.Parquet.Shards
    }
    for shardID := 0; shardID < numShards; shardID++ {
    idx := shardIdx
    shardIdx++
    ), and the store-gateway does the same using the bucket index or the converter mark (
    shardCounts, err := p.resolveShardCounts(ctx, blockIDs)
    if err != nil {
    return nil, err
    }
    var shardBlockIDs []string
    var shardIDs []int
    for _, blockID := range blockIDs {
    numShards, ok := shardCounts[blockID]
    if !ok {
    // The bucket index may not carry this block's shard count yet, for example
    // right after the block has been converted but before the index has been
    // refreshed. In that case, read the converter mark directly to get the
    // actual shard count instead of assuming a single shard.
    numShards, err = p.shardCountFromConverterMark(ctx, blockID)
    if err != nil {
    return nil, err
    }
    }
    if numShards <= 0 {
    // backward compatibility: blocks without a shard count have one shard
    numShards = 1
    }
    for shardID := 0; shardID < numShards; shardID++ {
    shardBlockIDs = append(shardBlockIDs, blockID)
    shardIDs = append(shardIDs, shardID)
    }
    ). Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions