Skip to content

Commit d221669

Browse files
committed
fix(posts_insights): fix missing table name changing before bg insert
1 parent 6f11389 commit d221669

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

dags/utils/posts_insights/base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,21 @@ def _dump_to_bigquery(
126126
logger.info(f"No {dump_type} to dump!")
127127
return
128128

129+
if dump_type == "posts":
130+
target_table = self.POST_TABLE_NAME
131+
elif dump_type == "posts insights":
132+
target_table = self.INSIGHT_TABLE_NAME
133+
else:
134+
raise ValueError(f"Unexpected dump_type {dump_type}")
135+
129136
job_config = bigquery.LoadJobConfig(
130137
schema=bq_schema_fields,
131138
write_disposition="WRITE_APPEND",
132139
)
133140
try:
134141
job = self.bq_client.load_table_from_json(
135142
posts,
136-
f"pycontw-225217.ods.{self.INSIGHT_TABLE_NAME}",
143+
f"pycontw-225217.ods.{target_table}",
137144
job_config=job_config,
138145
)
139146
job.result()

0 commit comments

Comments
 (0)