Skip to content

LoadTableFromStorageJob: allow adding sources from blobs, bucket + glob #2126

@tseaver

Description

@tseaver

Default the initial source_uris to an empty list, then add methods to add extra sources. E.g.:

class LoadTableFromStorageJob(_AsyncJob):

    ...

    def __init__(self, name, destination, source_uris=(), client, schema=()):
        super(LoadTableFromStorageJob, self).__init__(name, client)
        self.destination = destination
        self.source_uris = list(source_uris)
        # Let the @property do validation.
        self.schema = schema
        self._configuration = _LoadConfiguration()

    ...

    def add_bucket_source(self, bucket, glob):
        """Add a source URI for blobs matching 'glob' in 'bucket'.

        :type bucket: string or :class:`~gcloud.storage.bucket.Bucket`
        :param bucket: bucket or bucket name

        :type glob: string
        :param glob: blob name or name prefix with '*'
        """
        if isinstance(bucket, Bucket):
            bucket = bucket.name
        self.source_uris.append('gs://%s/%s/' % (bucket, glob))

    def add_blob_source(self, blob):
        """Add a source URI for a single blob.

        :type blob: :class:`~gcloud.storage.blob.Blob`
        :param blob: blob
        """
        bucket = blob.bucket.name
        self.source_uris.append('gs://%s/%s/' % (bucket, blob.name))

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions