[ 
https://issues.apache.org/jira/browse/BEAM-6892?focusedWorklogId=219173&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-219173
 ]

ASF GitHub Bot logged work on BEAM-6892:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 27/Mar/19 06:44
            Start Date: 27/Mar/19 06:44
    Worklog Time Spent: 10m 
      Work Description: pabloem commented on pull request #8093: [BEAM-6892] 
Schemas and destinations are provided to WriteToBigQuery separately
URL: https://github.com/apache/beam/pull/8093#discussion_r269422312
 
 

 ##########
 File path: sdks/python/apache_beam/io/gcp/bigquery_file_loads.py
 ##########
 @@ -490,18 +512,39 @@ def __init__(
     # job to run - and thus we avoid using temporary tables
     self.temp_tables = True if callable(destination) else False
 
+    self._validate = validate
+    if self._validate:
+      self.verify()
+
+  def verify(self):
+    if (isinstance(self._custom_gcs_temp_location, str) and
+        not self._custom_gcs_temp_location.startswith('gs://')):
+      # Only fail if the custom location is provided, and it is not a GCS
+      # location.
+      raise ValueError('Invalid GCS location.\n'
+                       'Writing to BigQuery with FILE_LOADS method requires a '
+                       'GCS location to be provided to write files to be '
+                       'loaded into BigQuery. Please provide a GCS bucket, or '
+                       'pass method="STREAMING_INSERTS" to WriteToBigQuery.')
+
   def expand(self, pcoll):
     p = pcoll.pipeline
 
+    self._custom_gcs_temp_location = (
+        self._custom_gcs_temp_location
+        or p.options.view_as(GoogleCloudOptions).temp_location)
+
     load_job_name_pcv = pvalue.AsSingleton(
         p
         | "ImpulseJobName" >> beam.Create([None])
         | beam.Map(lambda _: _generate_load_job_name()))
 
     file_prefix_pcv = pvalue.AsSingleton(
         p
-        | "CreateFilePrefixView" >> beam.Create([self._input_gs_location])
-        | "GenerateFilePrefix" >> beam.Map(_generate_file_prefix))
+        | "CreateFilePrefixView" >> beam.Create(
+            [self._custom_gcs_temp_location])
 
 Review comment:
   I've added a TODO. I'll add that in a later change.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 219173)
    Time Spent: 3h 20m  (was: 3h 10m)

> Use temp_location for BQ FILE_LOADS on DirectRunner, and autocreate it in GCS 
> if not specified by user.
> -------------------------------------------------------------------------------------------------------
>
>                 Key: BEAM-6892
>                 URL: https://issues.apache.org/jira/browse/BEAM-6892
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core
>            Reporter: Valentyn Tymofieiev
>            Assignee: Pablo Estrada
>            Priority: Major
>             Fix For: 2.13.0
>
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to