-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Change in TableId behaviour for non default BigQueryClient project 1.44 -> 1.45 #3808
Comments
@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). |
@MMMarcy that would work for us. It is more suitable to have this logic in BigQueryImpl. Thanks |
Perfect. Waiting for the owners thoughts now. If positive, I can open a PR |
Actually, thinking more about this using the proposed solution I mentioned hides too much of the behavior to the caller. Maybe overloading the public Table getTable(TableId tableId, ProjectId projectId, TableOption... options) {
...
} seems a better alternative. |
TableId already has a factory method including the project:
I would suggest that if the project is set in TableId, the developer knows the project he/she wants. |
Now getTable of BigQueryImpl checks if the provided TableId has the project set. If yes, the set projectId is used, otherwise the projectId used when creating the BigQuery client will be used. The additional test checks this behavior by calling getTableId with an empty projectId.
Unless I've missed something obvious folks, I think this issue needs to be reopened. The PR only fixed the |
@MMMarcy Can this issue be reopened and all occurrences be fixed or the original change reverted? |
@JesseLovelace PTAL |
Hey Folks - happy to open new issue(s) if that's what is needed to get this fixed up? Just let me know. |
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. |
I think there's way more callsites of |
@MMMarcy given the extent of the breakage - what was the motivation behind the original change? The |
@pmakani, it looks like there are more places that need to change. |
@chingor13 I was about to ask the same. He's all the references I see to |
Hi, we believe this is still broken as of today (1.65.0). As in the description of this ticket, still 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 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 Thanks! |
Now getTable of BigQueryImpl checks if the provided TableId has the project set. If yes, the set projectId is used, otherwise the projectId used when creating the BigQuery client will be used. The additional test checks this behavior by calling getTableId with an empty projectId.
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.
this is due to the change in TableId
In BigQueryImpl:
TableId old code:
TableId new code:
The text was updated successfully, but these errors were encountered: