From 0f89f5e39cf6d44a06cead2a9028987f35b8ce08 Mon Sep 17 00:00:00 2001 From: Henry Lee Date: Tue, 18 Jun 2024 20:36:05 +0800 Subject: [PATCH 1/2] fix(ods): sql script path --- dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py b/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py index 28330da..e460b11 100644 --- a/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py +++ b/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py @@ -17,8 +17,10 @@ def create_table_if_needed() -> None: client = bigquery.Client(project=os.getenv("BIGQUERY_PROJECT")) + base_path = Path(__file__).parent.parent + sql_path = base_path / "sql" / "create_table.sql" sql = ( - Path("dags/ods/kktix_ticket_orders/sqls/create_table.sql") + sql_path .read_text() .format(TABLE) ) From 2ae1d00f33807e64734ae23e6aec2ef05fa5f52e Mon Sep 17 00:00:00 2001 From: Henry Lee Date: Tue, 18 Jun 2024 20:39:47 +0800 Subject: [PATCH 2/2] refactor(ods): format --- dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py b/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py index e460b11..d964f13 100644 --- a/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py +++ b/dags/ods/kktix_ticket_orders/udfs/bigquery_loader.py @@ -19,10 +19,6 @@ def create_table_if_needed() -> None: client = bigquery.Client(project=os.getenv("BIGQUERY_PROJECT")) base_path = Path(__file__).parent.parent sql_path = base_path / "sql" / "create_table.sql" - sql = ( - sql_path - .read_text() - .format(TABLE) - ) + sql = sql_path.read_text().format(TABLE) client.query(sql) client.query(DEDUPE_SQL)