Skip to content

Commit

Permalink
fix(bigquery): missing schema for empty result set on stateless queri…
Browse files Browse the repository at this point in the history
…es (#10935)
  • Loading branch information
alvarowolfx authored Sep 30, 2024
1 parent 015b52c commit 28a069a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bigquery/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3581,6 +3581,9 @@ func compareRead(it *RowIterator, want [][]Value, compareTotalRows bool) (msg st
if err != nil {
return err.Error(), false
}
if want != nil && len(it.Schema) == 0 {
return "missing schema", false
}
if len(got) != len(want) {
return fmt.Sprintf("%s got %d rows, want %d", jobStr, len(got), len(want)), false
}
Expand Down
7 changes: 6 additions & 1 deletion bigquery/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ func fetchPage(ctx context.Context, src *rowSource, schema Schema, startIndex ui
return fetchTableResultPage(ctx, src, schema, startIndex, pageSize, pageToken)
}
// No rows, but no table or job reference. Return an empty result set.
return &fetchPageResult{}, nil
if schema == nil {
schema = bqToSchema(src.cachedSchema)
}
return &fetchPageResult{
schema: schema,
}, nil
}
return result, nil
}
Expand Down

0 comments on commit 28a069a

Please sign in to comment.