[
https://issues.apache.org/jira/browse/BEAM-6892?focusedWorklogId=218367&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-218367
]
ASF GitHub Bot logged work on BEAM-6892:
----------------------------------------
Author: ASF GitHub Bot
Created on: 26/Mar/19 00:16
Start Date: 26/Mar/19 00:16
Worklog Time Spent: 10m
Work Description: udim commented on pull request #8135: [BEAM-6892]
Adding support for auto-creating buckets for BigQuery file loads
URL: https://github.com/apache/beam/pull/8135#discussion_r268890089
##########
File path: sdks/python/apache_beam/io/gcp/bigquery_file_loads.py
##########
@@ -490,9 +498,93 @@ def __init__(
# job to run - and thus we avoid using temporary tables
self.temp_tables = True if callable(destination) else False
+ self.kms_key = kms_key
+
+ self._validate = validate
+
+ def verify(self, options):
+
+ self._custom_gcs_temp_location = (
+ self._custom_gcs_temp_location
+ or options.view_as(GoogleCloudOptions).temp_location)
+
+ if (not self._custom_gcs_temp_location or
+ not self._custom_gcs_temp_location.startswith('gs://')):
+
+ logging.info('No appropriate location was provided to perform file loads'
+ 'to GCS.')
+ bucket = self.try_to_create_default_gcs_bucket(options)
+
+ if bucket:
+ self._custom_gcs_temp_location = 'gs://%s/temp/' % bucket.name
+ return
+
+ 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 try_to_create_default_gcs_bucket(self, options):
+ DEFAULT_BUCKET_NAME = "dataflow-staging-%s-%s"
Review comment:
I think this feature is better placed in something like dataflow_runner.py,
because it's not BQ-specific. For example we could use this bucket when the
--staging_location option is not given (like the Java SDK does).
----------------------------------------------------------------
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: 218367)
Time Spent: 20m (was: 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: Blocker
> Fix For: 2.12.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)