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 — Change in TableId behaviour for non default BigQueryClient project 1.44 -> 1.45 · Issue #3808 · googleapis/google-cloud-java

Change in TableId behaviour for non default BigQueryClient project 1.44 -> 1.45 #3808

New issue
Copy link
New issue
Copy link
Closed
#4227
Closed
Change in TableId behaviour for non default BigQueryClient project 1.44 -> 1.45#3808
#4227
Copy link
Assignees
pmakani
Labels
🚨 criticalP0 critical issue. Requires immediate fixapi: bigqueryIssues related to the BigQuery API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@NickApostolidesMatillion
NickApostolidesMatillion
opened on Oct 11, 2018
Issue body actions

When using the getTable method of the BigQuery client the project of the TableId is overwritten. TableId would previously ignore this if a project had been set. Table Id has been changed such that the project is always overwritten. There is now no way to get a table for a project other than the one the client was created for.

TableId tableId = TableId.of(project, schema, tableName);
Table table = client.getTable(tableId);
// table returns null if project != client.getOptions().getProjectId()

this is due to the change in TableId

In BigQueryImpl:

public Table getTable(TableId tableId, TableOption... options) {
    final TableId completeTableId = tableId.setProjectId(getOptions().getProjectId());
    ...

TableId old code:

TableId setProjectId(String projectId) {
  return getProject() != null ? this : TableId.of(projectId, getDataset(), getTable());
}

TableId new code:

TableId setProjectId(String projectId) {
  Preconditions
    .checkArgument(!Strings.isNullOrEmpty(projectId), "Provided projectId is null or empty");
  return TableId.of(projectId, getDataset(), getTable());
}

Activity

Next
  1. JustinBeckwith
    added
    triage meI really want to be triaged.
    on Oct 12, 2018
  2. sduskis
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: bigqueryIssues related to the BigQuery API.
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on Oct 14, 2018
  3. JustinBeckwith
    added
    🚨 criticalP0 critical issue. Requires immediate fix
    on Oct 16, 2018
  4. MMMarcy commented on Oct 17, 2018

    @MMMarcy
    MMMarcy
    on Oct 17, 2018
    More actions

    @NickApostolidesMatillion I'm the author of that change. It was due to #3283 and this behavior is definitely unintended. However, reverting the change will re-open the mentioned issue.

    Perhaps something like:

    public Table getTable(TableId tableId, TableOption... options) {
    
        final TableId completeTableId = tableId.setProjectId(
            tableId.getProjectId() == null
            ? getOptions().getProjectId()
            : tableId.getProjectId()
        );
    ...
    }

    Would solve your issue and still keep the fix for #3283 (granted that now you supply a TableId with the desired projectId already set).

  5. NickApostolidesMatillion commented on Oct 17, 2018

    @NickApostolidesMatillion
    NickApostolidesMatillion
    on Oct 17, 2018
    Author
    More actions

    @MMMarcy that would work for us. It is more suitable to have this logic in BigQueryImpl.

    Thanks

  6. MMMarcy commented on Oct 17, 2018

    @MMMarcy
    MMMarcy
    on Oct 17, 2018
    More actions

    Perfect. Waiting for the owners thoughts now. If positive, I can open a PR

  7. MMMarcy commented on Oct 17, 2018

    @MMMarcy
    MMMarcy
    on Oct 17, 2018
    More actions

    Actually, thinking more about this using the proposed solution I mentioned hides too much of the behavior to the caller. Maybe overloading the getTable method with

    public Table getTable(TableId tableId, ProjectId projectId, TableOption... options) {
    ...
    }

    seems a better alternative.

  8. NickApostolidesMatillion commented on Oct 17, 2018

    @NickApostolidesMatillion
    NickApostolidesMatillion
    on Oct 17, 2018
    Author
    More actions

    TableId already has a factory method including the project:

    public static TableId of(String project, String dataset, String table)

    I would suggest that if the project is set in TableId, the developer knows the project he/she wants.

  9. JustinBeckwith
    assigned
    JesseLovelace
    on Oct 17, 2018
  10. JustinBeckwith
    added
    🚨 criticalP0 critical issue. Requires immediate fix
    and removed
    🚨 criticalP0 critical issue. Requires immediate fix
    triage meI really want to be triaged.
    on Oct 17, 2018
  11. 12 remaining items

  12. polleyg commented on Nov 22, 2018

    @polleyg
    polleyg
    on Nov 22, 2018
    More actions

    Hey Folks - any chance of getting someone to look at this? It's becoming a bit of a problem now. Maybe reverting the original change should be considered.

  13. chingor13
    closed this as completedin #4115on Nov 30, 2018
  14. mikekap commented on Dec 3, 2018

    @mikekap
    mikekap
    on Dec 3, 2018
    More actions

    I think there's way more callsites of setProjectId that aren't fixed - including insertAll that are still broken. IntelliJ shows 15 usages of which 3 are fixed now.

  15. mikekap commented on Dec 6, 2018

    @mikekap
    mikekap
    on Dec 6, 2018
    More actions

    @MMMarcy given the extent of the breakage - what was the motivation behind the original change? The setProjectId method is package-private so it shouldn't have been called externally.

  16. sduskis
    reopened this on Dec 6, 2018
  17. sduskis commented on Dec 6, 2018

    @sduskis
    sduskis
    on Dec 6, 2018
    Contributor
    More actions

    @pmakani, it looks like there are more places that need to change.

  18. JesseLovelace
    closed this as completedin #4196on Dec 12, 2018
  19. chingor13 commented on Dec 12, 2018

    @chingor13
    chingor13
    on Dec 12, 2018
    Contributor
    More actions

    @pmakani Did #4196 actually fix all the cases?

  20. chingor13
    reopened this on Dec 12, 2018
  21. polleyg commented on Dec 13, 2018

    @polleyg
    polleyg
    on Dec 13, 2018
    More actions

    @chingor13 I was about to ask the same. He's all the references I see to setProject() in my IDEA..
    screen shot 2018-12-13 at 11 00 13 am

  22. JesseLovelace
    closed this as completedin #4227on Dec 14, 2018
  23. lepistone commented on Mar 21, 2019

    @lepistone
    lepistone
    on Mar 21, 2019
    More actions

    Hi, we believe this is still broken as of today (1.65.0). As in the description of this ticket, still There is now no way to get a table for a project other than the one the client was created for.

    Specifically, in https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java#L635-L639 , the project in my tableId will always be overridden with the project of the service, if the service has a project.

    Maybe the intention of that code was to override the project only if it is not set in tableId? Then the code would look like

              tableId.setProjectId(
                  Strings.isNullOrEmpty(tableId.getProjectId())
                      ? serviceOptions.getProjectId());
                      : tableId.getProject()

    Or maybe, the confusion arose between TableId and TableInfo. The code above calls TableId::setProject, which will always perform the change. See: https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableId.java#L100

    Thanks!

    Reacted by Misha Kozik
  24. JesseLovelace
    assigned
    pmakani
    and unassigned
    JesseLovelace
    on May 1, 2019
  25. stephaniewang526
    added a commit that references this issue on Dec 6, 2019

    Fixes googleapis/google-cloud-java#3808. (#3873)

    This issue will close once commit 97a3e14 is merged into the 'main' branch.
    97a3e14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @pmakani
    pmakani

Labels

🚨 criticalP0 critical issue. Requires immediate fixapi: bigqueryIssues related to the BigQuery API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.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

    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.