GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BigQuery listTables(DatasetId) does not use project overrided in DatasetId · Issue #1123 · googleapis/google-cloud-java

BigQuery listTables(DatasetId) does not use project overrided in DatasetId #1123

New issue
Copy link
New issue
Copy link
Closed
#1217
Closed
BigQuery listTables(DatasetId) does not use project overrided in DatasetId#1123
#1217
Copy link
Assignees
mziccard
Labels
api: bigqueryIssues related to the BigQuery API.

Description

@tswast
tswast
opened on Jul 21, 2016
Issue body actions

My Google Application Default Credentials are set to the swast-scratch project, but I wish to list the tables in the publicdata project's samples dataset. This is a public dataset.

$ bq ls publicdata:samples
      tableId       Type
 ----------------- -------
  github_nested     TABLE
  github_timeline   TABLE
  gsod              TABLE
  natality          TABLE
  shakespeare       TABLE
  trigrams          TABLE
  wikipedia         TABLE

Example code that displays this issue:

import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.DatasetId;
import com.google.cloud.bigquery.Table;
import java.io.PrintWriter;
import java.util.Iterator;

public class TableLister {
  public static void listTables(PrintWriter out) {
    BigQuery bigquery = BigQueryOptions.defaultInstance().service();
    Iterator<Table> tables = bigquery.listTables(DatasetId.of("publicdata", "samples")).iterateAll();
    while (tables.hasNext()) {
      out.println(tables.next());
    }
  }

  public static void main(String[] args) {
    listTables(new PrintWriter(System.out));
  }
}

It fails with the error: "message" : "Not found: Dataset swast-scratch:samples", so it appears that it is not using the project that I set in the DatasetId.

http://googlecloudplatform.github.io/gcloud-java/0.2.5/apidocs/com/google/cloud/bigquery/DatasetId.html#of-java.lang.String-java.lang.String-

Activity

  1. tswast
    added
    api: bigqueryIssues related to the BigQuery API.
    on Jul 21, 2016
  2. mziccard commented on Jul 21, 2016

    @mziccard
    mziccard
    on Jul 21, 2016
    Contributor
    More actions

    Hi Tim!

    Actually this behavior is intended. All service operations (create/delete/get/list) are tied to the project id you provided to BigQueryOptions. The reason for which DatasetId and TableId also expose factory methods that take a projectId is that jobs (for instance a copy job) can be created in your bigqueryOptions.projectId() project and operate on tables and datasets of a different project.

    Do you have a specific use case for creating BigQueryOptions with a project id and list tables that reside in a dataset of a different project?

  3. tswast commented on Jul 21, 2016

    @tswast
    tswast
    on Jul 21, 2016
    ContributorAuthor
    More actions

    Well for public datasets I don't have permission to access the BigQuery API
    through them, but I do want to access those tables. It seems weird to say
    that to read from a public dataset I need to connect to that project when I
    create the service object.

  4. tswast commented on Jul 22, 2016

    @tswast
    tswast
    on Jul 22, 2016
    ContributorAuthor
    More actions

    So, it looks like I can work around this issue using BigQueryOptions, but it does feel wrong.

    BigQuery bigquery = BigQueryOptions.builder().projectId("publicdata").build().service();
    Iterator<Table> tables = bigquery.listTables(DatasetId.of("samples")).iterateAll();
    while (tables.hasNext()) {
      out.println(tables.next());
    }
    

    I'm not a member of the publicdata project, so it feels strange to connect to it like this.

  5. tswast commented on Jul 22, 2016

    @tswast
    tswast
    on Jul 22, 2016
    ContributorAuthor
    More actions

    At the very least, we should raise an exception if the project ID is populated in the DatasetId.

    It should not be silently ignored.

  6. mziccard commented on Aug 8, 2016

    @mziccard
    mziccard
    on Aug 8, 2016
    Contributor
    More actions

    I gave some thoughts on this and I think you are right. I'll try to wrap up a PR, I'll CC you so you can give it a try as soon as it's ready.

  7. mziccard
    closed this as completedin #1217on Sep 1, 2016
  8. JustinBeckwith
    assigned
    mziccard
    on Feb 1, 2021
  9. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore(deps): update dependency com.google.cloud:google-cloud-logging …

    8e29548
  10. chingor13
    added a commit that references this issue on Jan 6, 2026

    chore(main): release 0.130.17-alpha (#1123)

    79b2a5e
  11. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-datastor…

    917e7c8
  12. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-logging …

    c13aa34
  13. suztomo
    added a commit that references this issue on Mar 23, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-spanner-…

    9ca789b
  14. suztomo
    added a commit that references this issue on Mar 30, 2026

    build(deps): update releasetool version for release scripts (#1768) (#…

    dfc23f7
  15. lqiu96
    added a commit that references this issue on Apr 1, 2026

    build(deps): update releasetool version for release scripts (#1768) (#…

    b88da6c
  16. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v24.…

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

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.