Skip to content

Conversation

@shollyman
Copy link
Contributor

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

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.
@shollyman shollyman requested a review from alvarowolfx December 1, 2025 23:00
@shollyman shollyman requested review from a team as code owners December 1, 2025 23:00
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the BigQuery API. label Dec 1, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @shollyman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request modernizes the BigQuery client library by transitioning its timestamp output formatting mechanism. It replaces the older boolean flag UseInt64Timestamp with the more explicit TimestampOutputFormat string option, setting it to "INT64". This ensures that all relevant BigQuery API calls and query configurations consistently use the updated format, laying the groundwork for future enhancements, such as supporting ISO string timestamp output.

Highlights

  • API Transition: Migrated BigQuery API calls from using the deprecated UseInt64Timestamp boolean option to the newer TimestampOutputFormat string option, specifying "INT64".
  • Codebase Modernization: Updated various BigQuery client methods and query configurations across iterator.go, job.go, and query.go to align with the updated timestamp formatting approach.
  • Future-proofing: This change is a preparatory step for subsequent pull requests that will introduce ISO string output for timestamps, as noted in the PR description.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly transitions from the deprecated UseInt64Timestamp boolean to the TimestampOutputFormat option for BigQuery calls, setting it to "INT64". The changes are applied consistently across all relevant call sites and tests. My main feedback is to define the string "INT64" as a constant to avoid magic strings and improve maintainability. This is particularly relevant as a follow-up PR is planned to change this value, and using a constant would make that change safer and more explicit. I've left comments on each occurrence.

}
call := src.t.c.bqs.Tabledata.List(src.t.ProjectID, src.t.DatasetID, src.t.TableID)
call = call.FormatOptionsUseInt64Timestamp(true)
call = call.FormatOptionsTimestampOutputFormat("INT64")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and avoid using a "magic string", consider defining "INT64" as a constant. This string appears in multiple files in this PR. Creating a constant, for example const timestampOutputFormatInt64 = "INT64", in a suitable shared location would make the code more readable and easier to update. The PR description mentions a future change to an ISO string format, which would be simpler and safer to implement with a constant.

projectedFields := []googleapi.Field{"rows", "pageToken", "totalRows"}
call := src.j.c.bqs.Jobs.GetQueryResults(src.j.projectID, src.j.jobID).Location(src.j.location).Context(ctx)
call = call.FormatOptionsUseInt64Timestamp(true)
call = call.FormatOptionsTimestampOutputFormat("INT64")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As with the other call sites, replacing the magic string "INT64" with a shared constant would improve maintainability.

// Use GetQueryResults only to wait for completion, not to read results.
call := j.c.bqs.Jobs.GetQueryResults(projectID, j.jobID).Location(j.location).Context(ctx).MaxResults(0)
call = call.FormatOptionsUseInt64Timestamp(true)
call = call.FormatOptionsTimestampOutputFormat("INT64")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using a constant for "INT64" to avoid magic strings and improve code clarity and maintainability. This is especially relevant given the planned future changes to this format option.

Labels: q.Labels,
FormatOptions: &bq.DataFormatOptions{
UseInt64Timestamp: true,
TimestampOutputFormat: "INT64",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The string literal "INT64" is used in multiple places. It would be better to define this as a constant to improve maintainability and prevent potential typos. This also makes it easier to change the format in the future, as mentioned in the PR description.

UseLegacySql: &pfalse,
FormatOptions: &bq.DataFormatOptions{
UseInt64Timestamp: true,
TimestampOutputFormat: "INT64",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure consistency and improve maintainability, this test should also use the proposed constant for "INT64" instead of a magic string.

UseQueryCache: &pfalse,
FormatOptions: &bq.DataFormatOptions{
UseInt64Timestamp: true,
TimestampOutputFormat: "INT64",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the other test case, using a constant for "INT64" here will make the test suite more robust to future changes of this format option.

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

Labels

api: bigquery Issues related to the BigQuery API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant