beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BEAM-3452) NullPointerException when executing BigQuerySourceBase.split()
Date Sat, 13 Jan 2018 00:05:00 GMT

    [ https://issues.apache.org/jira/browse/BEAM-3452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16324764#comment-16324764
] 

ASF GitHub Bot commented on BEAM-3452:
--------------------------------------

chamikaramj closed pull request #4390: [BEAM-3452] Updates the error message when trying to
execute an export job on a non-existing BQ table.
URL: https://github.com/apache/beam/pull/4390
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySourceBase.java
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySourceBase.java
index ca900d6d216..a15afed8f0b 100644
--- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySourceBase.java
+++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySourceBase.java
@@ -26,6 +26,7 @@
 import com.google.api.services.bigquery.model.Job;
 import com.google.api.services.bigquery.model.JobConfigurationExtract;
 import com.google.api.services.bigquery.model.JobReference;
+import com.google.api.services.bigquery.model.Table;
 import com.google.api.services.bigquery.model.TableReference;
 import com.google.api.services.bigquery.model.TableSchema;
 import com.google.common.base.Function;
@@ -100,8 +101,14 @@ public ExtractResult(TableSchema schema, List<ResourceId> extractedFiles)
{
   protected ExtractResult extractFiles(PipelineOptions options) throws Exception {
     BigQueryOptions bqOptions = options.as(BigQueryOptions.class);
     TableReference tableToExtract = getTableToExtract(bqOptions);
-    TableSchema schema =
-        bqServices.getDatasetService(bqOptions).getTable(tableToExtract).getSchema();
+    Table table = bqServices.getDatasetService(bqOptions).getTable(tableToExtract);
+    if (table == null) {
+      throw new IOException(String.format(
+              "Cannot start an export job since table %s does not exist",
+              BigQueryHelpers.toTableSpec(tableToExtract)));
+    }
+
+    TableSchema schema = table.getSchema();
     JobService jobService = bqServices.getJobService(bqOptions);
     String extractJobId = getExtractJobId(createJobIdToken(options.getJobName(), stepUuid));
     final String extractDestinationDir =


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> NullPointerException when executing BigQuerySourceBase.split()
> --------------------------------------------------------------
>
>                 Key: BEAM-3452
>                 URL: https://issues.apache.org/jira/browse/BEAM-3452
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-gcp
>            Reporter: Chamikara Jayalath
>            Assignee: Chamikara Jayalath
>
> If we try to try to start an BQ export job (during read) for a non-existing table we'll
get an NullPointerException at [1] due to 'null' being returned at [2].
> [1] https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySourceBase.java#L104
> [2] https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java#L430



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message