Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset.getCreationTime() is returning null #848

Closed
stephaniewang526 opened this issue Oct 22, 2020 · 2 comments · Fixed by #866
Closed

Dataset.getCreationTime() is returning null #848

stephaniewang526 opened this issue Oct 22, 2020 · 2 comments · Fixed by #866
Assignees
Labels
api: bigquery Issues related to the googleapis/java-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@stephaniewang526
Copy link
Contributor

stephaniewang526 commented Oct 22, 2020

Below method is retuning null:

  public Long getCreationTime() {
    return this.creationTime;
  }

Tested in below snippet:

    Page<Dataset> datasets = bigquery.listDatasets(PROJECT_ID, DatasetListOption.pageSize(1000));
    for (Dataset dataset : datasets.getValues()) {
      String datasetName = dataset.getDatasetId().getDataset();
      if ((datasetName.contains("CREATE_DATASET_AWS_TEST_")
              || datasetName.contains("MY_DATASET_")
              || datasetName.contains("gcloud_test_")
              || datasetName.contains("SHARED_DATASET_TEST_"))
          && dataset.getCreationTime() > sixHourAgo) {
        System.out.format("\tDeleting Dataset: %s\n", datasetName);
        bigquery.delete(
            DatasetId.of(PROJECT_ID, datasetName), BigQuery.DatasetDeleteOption.deleteContents());
      }
    }
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/java-bigquery API. label Oct 22, 2020
@stephaniewang526 stephaniewang526 self-assigned this Oct 22, 2020
@stephaniewang526 stephaniewang526 changed the title getCreationTime() is null Dataset.getCreationTime() is returning null Oct 22, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Oct 23, 2020
@stephaniewang526
Copy link
Contributor Author

"creationTime": "1603486910742" --> returned from backend.

@shollyman
Copy link
Contributor

this is due to partial projection behavior. datasets.list doesn't return all fields, you need to issue a datasets.get if you want everything.

under the hood, this is com.google.api.services.bigquery.model.DatasetList.Datasets vs com.google.api.services.bigquery.model.Dataset

@pmakani pmakani added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed triage me I really want to be triaged. waiting on backend labels Oct 26, 2020
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 googleapis/java-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants