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


##########
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:
   Actually L685 and L697 is identical (which means L692-L701 won't help)
   
   For Dataflow pipeline --project is required so L703 and below isn't useful 
either



##########
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

Review Comment:
   it appears the current code already handles default project id, as fixed in 
#29471



-- 
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