Skip to content

Commit 13bbcdc

Browse files
authored
Add 'ExternalSourceFormat' enum. (googleapis#5674)
Closes googleapis#5499.
1 parent 814e75b commit 13bbcdc

4 files changed

Lines changed: 48 additions & 12 deletions

File tree

bigquery/google/cloud/bigquery/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
from google.cloud.bigquery.dataset import AccessEntry
3636
from google.cloud.bigquery.dataset import Dataset
3737
from google.cloud.bigquery.dataset import DatasetReference
38+
from google.cloud.bigquery.external_config import ExternalConfig
39+
from google.cloud.bigquery.external_config import BigtableOptions
40+
from google.cloud.bigquery.external_config import BigtableColumnFamily
41+
from google.cloud.bigquery.external_config import BigtableColumn
42+
from google.cloud.bigquery.external_config import CSVOptions
43+
from google.cloud.bigquery.external_config import GoogleSheetsOptions
44+
from google.cloud.bigquery.external_config import ExternalSourceFormat
3845
from google.cloud.bigquery.job import Compression
3946
from google.cloud.bigquery.job import CopyJob
4047
from google.cloud.bigquery.job import CopyJobConfig
@@ -64,12 +71,6 @@
6471
from google.cloud.bigquery.table import Row
6572
from google.cloud.bigquery.table import TimePartitioningType
6673
from google.cloud.bigquery.table import TimePartitioning
67-
from google.cloud.bigquery.external_config import ExternalConfig
68-
from google.cloud.bigquery.external_config import BigtableOptions
69-
from google.cloud.bigquery.external_config import BigtableColumnFamily
70-
from google.cloud.bigquery.external_config import BigtableColumn
71-
from google.cloud.bigquery.external_config import CSVOptions
72-
from google.cloud.bigquery.external_config import GoogleSheetsOptions
7374

7475
__all__ = [
7576
'__version__',
@@ -112,6 +113,7 @@
112113
'Compression',
113114
'CreateDisposition',
114115
'DestinationFormat',
116+
'ExternalSourceFormat',
115117
'Encoding',
116118
'QueryPriority',
117119
'SchemaUpdateOption',

bigquery/google/cloud/bigquery/external_config.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,33 @@
2929
from google.cloud.bigquery.schema import SchemaField
3030

3131

32+
class ExternalSourceFormat(object):
33+
"""The format for external data files..
34+
35+
Note that the set of allowed values for external data sources is different
36+
than the set used for loading data (see
37+
:class:`~google.cloud.bigquery.job.SourceFormat`).
38+
"""
39+
40+
CSV = 'CSV'
41+
"""Specifies CSV format."""
42+
43+
GOOGLE_SHEETS = 'GOOGLE_SHEETS'
44+
"""Specifies Google Sheets format."""
45+
46+
NEWLINE_DELIMITED_JSON = 'NEWLINE_DELIMITED_JSON'
47+
"""Specifies newline delimited JSON format."""
48+
49+
AVRO = 'AVRO'
50+
"""Specifies Avro format."""
51+
52+
DATASTORE_BACKUP = 'DATASTORE_BACKUP'
53+
"""Specifies datastore backup format"""
54+
55+
BIGTABLE = 'BIGTABLE'
56+
"""Specifies Bigtable format."""
57+
58+
3259
class BigtableColumn(object):
3360
"""Options for a Bigtable column."""
3461

@@ -516,9 +543,9 @@ def from_api_repr(cls, resource):
516543
class ExternalConfig(object):
517544
"""Description of an external data source.
518545
519-
:type source_format: str
520-
:param source_format: the format of the external data. See
521-
the ``source_format`` property on this class.
546+
Args:
547+
source_format :class:`ExternalSourceFormat`:
548+
See :attr:`source_format`.
522549
"""
523550

524551
def __init__(self, source_format):
@@ -531,8 +558,9 @@ def __init__(self, source_format):
531558

532559
@property
533560
def source_format(self):
534-
"""See
535-
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.(key).sourceFormat
561+
""":class:`ExternalSourceFormat`: Format of external source.
562+
563+
See
536564
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#externalDataConfiguration.sourceFormat
537565
"""
538566
return self._properties['sourceFormat']

bigquery/google/cloud/bigquery/job.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ class QueryPriority(object):
166166

167167

168168
class SourceFormat(object):
169-
"""The format of the data files. The default value is :attr:`CSV`."""
169+
"""The format of the data files. The default value is :attr:`CSV`.
170+
171+
Note that the set of allowed values for loading data is different
172+
than the set used for external data sources (see
173+
:class:`~google.cloud.bigquery.external_config.ExternalSourceFormat`).
174+
"""
170175

171176
CSV = 'CSV'
172177
"""Specifies CSV format."""

docs/bigquery/reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ External Configuration
129129
.. autosummary::
130130
:toctree: generated
131131

132+
external_config.ExternalSourceFormat
132133
external_config.ExternalConfig
133134
external_config.BigtableOptions
134135
external_config.BigtableColumnFamily

0 commit comments

Comments
 (0)