Skip to content

Commit 46c9bdf

Browse files
committed
fix tenant filtering in union subqueries
1 parent 4c6243b commit 46c9bdf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/logstorage/storage_search.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ func (s *Storage) runQuery(qctx *QueryContext, writeBlock writeBlockResultFunc)
239239
// A non-empty TenantIDs means the caller already resolved the exact tenants to search
240240
// (e.g. the stream_context pipe scopes its subquery to a single tenant derived from the streamID).
241241
// Only resolve tenants from the query filter when the caller left TenantIDs unresolved.
242+
tenantIDs := qctx.TenantIDs
242243
if qctx.IsMultiTenant && len(qctx.TenantIDs) == 0 {
243-
tenantIDs, err := s.getTenantIDsForQuery(qctx.Context, q)
244+
tenantIDs, err = s.getTenantIDsForQuery(qctx.Context, q)
244245
if err != nil {
245246
return fmt.Errorf("cannot get tenant IDs: %w", err)
246247
}
247-
qctx.TenantIDs = tenantIDs
248248
}
249249

250-
sso := s.getSearchOptions(qctx.TenantIDs, qctx.IsMultiTenant, q, qctx.HiddenFieldsFilters)
250+
sso := s.getSearchOptions(tenantIDs, qctx.IsMultiTenant, q, qctx.HiddenFieldsFilters)
251251
search := func(stopCh <-chan struct{}, writeBlockToPipes writeBlockResultFunc) error {
252252
workersCount := q.GetParallelReaders(s.defaultParallelReaders)
253253
s.searchParallel(workersCount, sso, qctx.QueryStats, stopCh, writeBlockToPipes)

0 commit comments

Comments
 (0)