Skip to content

Commit 59efe32

Browse files
authored
feat(bigquery): transition format options (#13422)
This PR is minimal, and updates all callsites that use the older UseInt64Timestamp boolean for controlling output to instead use the newer TimestampOutputFormat option and specify it using INT64. Followup PRs will update this to use the new ISO string for output. Towards internal b/447623020
1 parent 0dd2a3b commit 59efe32

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

bigquery/iterator.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import (
2525
"google.golang.org/api/iterator"
2626
)
2727

28+
const (
29+
defaultTimestampWireFormat string = "INT64"
30+
)
31+
2832
// Construct a RowIterator.
2933
func newRowIterator(ctx context.Context, src *rowSource, pf pageFetcher) *RowIterator {
3034
it := &RowIterator{
@@ -290,7 +294,7 @@ func fetchTableResultPage(ctx context.Context, src *rowSource, schema Schema, st
290294
}()
291295
}
292296
call := src.t.c.bqs.Tabledata.List(src.t.ProjectID, src.t.DatasetID, src.t.TableID)
293-
call = call.FormatOptionsUseInt64Timestamp(true)
297+
call = call.FormatOptionsTimestampOutputFormat(defaultTimestampWireFormat)
294298
setClientHeader(call.Header())
295299
if pageToken != "" {
296300
call.PageToken(pageToken)
@@ -328,7 +332,7 @@ func fetchJobResultPage(ctx context.Context, src *rowSource, schema Schema, star
328332
// reduce data transferred by leveraging api projections
329333
projectedFields := []googleapi.Field{"rows", "pageToken", "totalRows"}
330334
call := src.j.c.bqs.Jobs.GetQueryResults(src.j.projectID, src.j.jobID).Location(src.j.location).Context(ctx)
331-
call = call.FormatOptionsUseInt64Timestamp(true)
335+
call = call.FormatOptionsTimestampOutputFormat(defaultTimestampWireFormat)
332336
if schema == nil {
333337
// only project schema if we weren't supplied one.
334338
projectedFields = append(projectedFields, "schema")

bigquery/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func (j *Job) read(ctx context.Context, waitForQuery func(context.Context, strin
353353
func (j *Job) waitForQuery(ctx context.Context, projectID string) (Schema, uint64, error) {
354354
// Use GetQueryResults only to wait for completion, not to read results.
355355
call := j.c.bqs.Jobs.GetQueryResults(projectID, j.jobID).Location(j.location).Context(ctx).MaxResults(0)
356-
call = call.FormatOptionsUseInt64Timestamp(true)
356+
call = call.FormatOptionsTimestampOutputFormat(defaultTimestampWireFormat)
357357
setClientHeader(call.Header())
358358
backoff := gax.Backoff{
359359
Initial: 50 * time.Millisecond,

bigquery/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func (q *Query) probeFastPath() (*bq.QueryRequest, error) {
500500
MaxSlots: int64(q.MaxSlots),
501501
Labels: q.Labels,
502502
FormatOptions: &bq.DataFormatOptions{
503-
UseInt64Timestamp: true,
503+
TimestampOutputFormat: defaultTimestampWireFormat,
504504
},
505505
}
506506
if q.QueryConfig.DisableQueryCache {

bigquery/query_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func TestProbeFastPath(t *testing.T) {
470470
Query: "foo",
471471
UseLegacySql: &pfalse,
472472
FormatOptions: &bq.DataFormatOptions{
473-
UseInt64Timestamp: true,
473+
TimestampOutputFormat: defaultTimestampWireFormat,
474474
},
475475
},
476476
},
@@ -509,7 +509,7 @@ func TestProbeFastPath(t *testing.T) {
509509
},
510510
UseQueryCache: &pfalse,
511511
FormatOptions: &bq.DataFormatOptions{
512-
UseInt64Timestamp: true,
512+
TimestampOutputFormat: defaultTimestampWireFormat,
513513
},
514514
Reservation: "reservation/1",
515515
MaxSlots: 222,

0 commit comments

Comments
 (0)