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 #3808Labels 🚨 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. DescriptionWhen 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());
}
Activityadded type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release. on Oct 14, 2018MMMarcy commented on Oct 17, 2018 @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). NickApostolidesMatillion commented on Oct 17, 2018 @MMMarcy that would work for us. It is more suitable to have this logic in BigQueryImpl.
Thanks MMMarcy commented on Oct 17, 2018 Perfect. Waiting for the owners thoughts now. If positive, I can open a PR MMMarcy commented on Oct 17, 2018 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. NickApostolidesMatillion commented on Oct 17, 2018 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. polleyg commented on Nov 22, 2018 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. mikekap commented on Dec 3, 2018 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. mikekap commented on Dec 6, 2018 @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. sduskis commented on Dec 6, 2018 @pmakani, it looks like there are more places that need to change. chingor13 commented on Dec 12, 2018 polleyg commented on Dec 13, 2018 @chingor13 I was about to ask the same. He's all the references I see to setProject() in my IDEA..
 lepistone commented on Mar 21, 2019 added a commit that references this issue on Dec 6, 2019This issue will close once commit 97a3e14 is merged into the 'main' branch.97a3e14
MetadataMetadata🚨 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. DevelopmentNo branches or pull requestsIssue actions
|