|
19 | 19 | import collections |
20 | 20 | import uuid |
21 | 21 |
|
| 22 | +import six |
| 23 | + |
22 | 24 | from google.api.core import page_iterator |
23 | 25 | from google.cloud.client import ClientWithProject |
24 | 26 | from google.cloud.bigquery._http import Connection |
@@ -490,26 +492,37 @@ def list_jobs(self, max_results=None, page_token=None, all_users=None, |
490 | 492 | max_results=max_results, |
491 | 493 | extra_params=extra_params) |
492 | 494 |
|
493 | | - def load_table_from_storage(self, job_id, destination, *source_uris): |
494 | | - """Construct a job for loading data into a table from CloudStorage. |
| 495 | + def load_table_from_storage(self, source_uris, destination, |
| 496 | + job_id=None, job_config=None): |
| 497 | + """Starts a job for loading data into a table from CloudStorage. |
495 | 498 |
|
496 | 499 | See |
497 | 500 | https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load |
498 | 501 |
|
499 | | - :type job_id: str |
500 | | - :param job_id: Name of the job. |
| 502 | + :type source_uris: One of: |
| 503 | + str |
| 504 | + sequence of string |
| 505 | + :param source_uris: URIs of data files to be loaded; in format |
| 506 | + ``gs://<bucket_name>/<object_name_or_glob>``. |
501 | 507 |
|
502 | | - :type destination: :class:`google.cloud.bigquery.table.Table` |
| 508 | + :type destination: :class:`google.cloud.bigquery.table.TableReference` |
503 | 509 | :param destination: Table into which data is to be loaded. |
504 | 510 |
|
505 | | - :type source_uris: sequence of string |
506 | | - :param source_uris: URIs of data files to be loaded; in format |
507 | | - ``gs://<bucket_name>/<object_name_or_glob>``. |
| 511 | + :type job_id: str |
| 512 | + :param job_id: Name of the job. |
| 513 | +
|
| 514 | + :type job_config: :class:`google.cloud.bigquery.job.LoadJobConfig` |
| 515 | + :param job_config: (Optional) Extra configuration options for the job. |
508 | 516 |
|
509 | 517 | :rtype: :class:`google.cloud.bigquery.job.LoadJob` |
510 | 518 | :returns: a new ``LoadJob`` instance |
511 | 519 | """ |
512 | | - return LoadJob(job_id, destination, source_uris, client=self) |
| 520 | + job_id = _make_job_id(job_id) |
| 521 | + if isinstance(source_uris, six.string_types): |
| 522 | + source_uris = [source_uris] |
| 523 | + job = LoadJob(job_id, source_uris, destination, self, job_config) |
| 524 | + job.begin() |
| 525 | + return job |
513 | 526 |
|
514 | 527 | def copy_table(self, sources, destination, job_id=None, job_config=None): |
515 | 528 | """Start a job for copying one or more tables into another table. |
|
0 commit comments