Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
This repository was archived by the owner on Aug 30, 2026. It is now read-only.

BigQuery:Java:Examples Incorrect example for setting expiration for the table  #1371

Description

@mixermt

Hi,

There is a small, but a misleading, bug in examples on how to set an expiration for the table in Java.

https://cloud.google.com/bigquery/docs/managing-tables#updating_a_tables_expiration_time

Relevant code:

Long newExpiration = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);

Expiration is shown in pure milliseconds of time and not in milliseconds since the epoch like stated in method documentation.

Instead, the example should use:

Long newExpiration = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS) + ZonedDateTime.now(ZoneOffset.UTC).toInstant().toEpochMilli();

or simple

Long newExpiration = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS) + System.currentTimeMillis();

Environment details

  1. OS type and version: Any
  2. Java version: 8
  3. bigquery version(s): 1.133.0

Steps to reproduce

  1. Just try an example and your table will disappear because the expiration date will be in the past

Activity

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

Metadata

Metadata

Labels

🚨This issue needs some love.api: bigqueryIssues related to the googleapis/java-bigquery API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions