Skip to content

Commit 1db67fd

Browse files
authored
Merge pull request #18 from johnf1004/dev
Labels
2 parents abf814d + 87bb10c commit 1db67fd

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

google_cloud_utilities/gcp.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def create_bq_table(table_id, partition_col, partition_type, schema, bq_client,
122122
)
123123
)
124124

125-
def create_bq_table_from_file(file, table_id, field_delimiter, partition_col, partition_type, schema, bq_client, partition_expiration=None, ignore_unknown_values=False):
125+
def create_bq_table_from_file(file, table_id, field_delimiter, partition_col, partition_type, schema, bq_client, partition_expiration=None, ignore_unknown_values=False, labels={}):
126126
"""
127127
Create a bigquery table from a local csv file
128128
@@ -143,7 +143,8 @@ def create_bq_table_from_file(file, table_id, field_delimiter, partition_col, pa
143143
skip_leading_rows=1, schema=schema,
144144
write_disposition=bigquery.job.WriteDisposition.WRITE_APPEND,
145145
field_delimiter=field_delimiter,
146-
ignore_unknown_values=ignore_unknown_values
146+
ignore_unknown_values=ignore_unknown_values,
147+
labels=labels
147148
)
148149

149150
if partition_col:
@@ -175,7 +176,7 @@ def create_bq_table_from_file(file, table_id, field_delimiter, partition_col, pa
175176
)
176177

177178

178-
def create_bq_table_from_file_json(table_id, schema, bq_client, partition_col=None, file=None, uri=None, partition_expiration=None, ignore_unknown_values=True):
179+
def create_bq_table_from_file_json(table_id, schema, bq_client, partition_col=None, file=None, uri=None, partition_expiration=None, ignore_unknown_values=True, labels={}):
179180
"""
180181
Create a bigquery table from a local csv file
181182
@@ -194,7 +195,8 @@ def create_bq_table_from_file_json(table_id, schema, bq_client, partition_col=No
194195
source_format=bigquery.SourceFormat.NEWLINE_DELIMITED_JSON,
195196
schema=schema,
196197
write_disposition=bigquery.job.WriteDisposition.WRITE_APPEND,
197-
ignore_unknown_values=ignore_unknown_values
198+
ignore_unknown_values=ignore_unknown_values,
199+
labels=labels
198200
)
199201

200202
if partition_col:
@@ -405,7 +407,8 @@ def append_rows_bq_json(rows_to_insert, table_id, bq_client, labels, schema, par
405407
source_format=bigquery.SourceFormat.NEWLINE_DELIMITED_JSON,
406408
write_disposition=bigquery.job.WriteDisposition.WRITE_APPEND,
407409
labels=labels,
408-
schema=schema
410+
schema=schema,
411+
labels=labels
409412
)
410413

411414
job = bq_client.load_table_from_json(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
EMAIL = 'johnf1004@yahoo.co.uk'
1313
AUTHOR = 'John Foley'
1414
REQUIRES_PYTHON = '>=3.9.7'
15-
VERSION = '0.8.4'
15+
VERSION = '0.8.5'
1616

1717
# What packages are required for this module to be executed?
1818
REQUIRED = [

0 commit comments

Comments
 (0)