@@ -56,6 +56,8 @@ class GCSToBigQueryOperator(BaseOperator):
56
56
:param schema_object: If set, a GCS object path pointing to a .json file that
57
57
contains the schema for the table. (templated)
58
58
Parameter must be defined if 'schema_fields' is null and autodetect is False.
59
+ :param schema_object_bucket: [Optional] If set, the GCS bucket where the schema object
60
+ template is stored. (templated) (Default: the value of ``bucket``)
59
61
:param source_format: File format to export.
60
62
:param compression: [Optional] The compression type of the data source.
61
63
Possible values include GZIP and NONE.
@@ -133,6 +135,7 @@ class GCSToBigQueryOperator(BaseOperator):
133
135
'bucket' ,
134
136
'source_objects' ,
135
137
'schema_object' ,
138
+ 'schema_object_bucket' ,
136
139
'destination_project_dataset_table' ,
137
140
'impersonation_chain' ,
138
141
)
@@ -147,6 +150,7 @@ def __init__(
147
150
destination_project_dataset_table ,
148
151
schema_fields = None ,
149
152
schema_object = None ,
153
+ schema_object_bucket = None ,
150
154
source_format = 'CSV' ,
151
155
compression = 'NONE' ,
152
156
create_disposition = 'CREATE_IF_NEEDED' ,
@@ -187,6 +191,10 @@ def __init__(
187
191
self .source_objects = source_objects
188
192
self .schema_object = schema_object
189
193
194
+ if schema_object_bucket is None :
195
+ schema_object_bucket = bucket
196
+ self .schema_object_bucket = schema_object_bucket
197
+
190
198
# BQ config
191
199
self .destination_project_dataset_table = destination_project_dataset_table
192
200
self .schema_fields = schema_fields
@@ -236,7 +244,7 @@ def execute(self, context: 'Context'):
236
244
impersonation_chain = self .impersonation_chain ,
237
245
)
238
246
blob = gcs_hook .download (
239
- bucket_name = self .bucket ,
247
+ bucket_name = self .schema_object_bucket ,
240
248
object_name = self .schema_object ,
241
249
)
242
250
schema_fields = json .loads (blob .decode ("utf-8" ))
0 commit comments