liferoad commented on code in PR #35047:
URL: https://github.com/apache/beam/pull/35047#discussion_r2110686883


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java:
##########
@@ -674,12 +674,37 @@ Table getTable(
         Sleeper sleeper)
         throws IOException, InterruptedException {
       TableReference updatedRef = ref.clone();
-      if (updatedRef.getProjectId() == null) {
+      if (Strings.isNullOrEmpty(updatedRef.getProjectId())) {
+        String projectIdToSet = null;
         BigQueryOptions bqOptions = options.as(BigQueryOptions.class);
-        updatedRef.setProjectId(
-            bqOptions.getBigQueryProject() == null
-                ? bqOptions.getProject()
-                : bqOptions.getBigQueryProject());
+
+        if (bqOptions != null) {
+          projectIdToSet = bqOptions.getBigQueryProject();
+          if (Strings.isNullOrEmpty(projectIdToSet)) {
+            // Try to get from GcpOptions via bqOptions
+            GcpOptions gcpOptionsFromBq = bqOptions.as(GcpOptions.class);
+            if (gcpOptionsFromBq != null) {
+              projectIdToSet = gcpOptionsFromBq.getProject();
+            }
+          }
+        }
+
+        // If still no project ID, try getting GcpOptions directly from the 
main 'options'
+        // This covers cases where 'options' might be GcpOptions but not 
BigQueryOptions,
+        // or if BigQueryOptions was present but didn't yield a project ID.
+        // This also handles the case where bqOptions itself was null.
+        if (Strings.isNullOrEmpty(projectIdToSet)) {

Review Comment:
   You are correct.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to