Skip to content

Commit

Permalink
debuga cvm_oferta_publica_distribuicao
Browse files Browse the repository at this point in the history
  • Loading branch information
folhesgabriel committed Sep 21, 2023
1 parent b584619 commit 882b91b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def extract_last_date(
table_id: str,
billing_project_id: str,
var_name: str,
) -> datetime:
) -> str:
"""
Extracts the last update date of a given dataset table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
materialize_after_dump = Parameter(
"materialize after dump", default=True, required=False
)
dbt_alias = Parameter("dbt_alias", default=False, required=False)
dbt_alias = Parameter("dbt_alias", default=True, required=False)
update_metadata = Parameter("update_metadata", default=False, required=False)

rename_flow_run = rename_current_flow_run_dataset_table(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
import os


import pandas as pd
from pandas.api.types import is_string_dtype
from prefect import task
Expand Down Expand Up @@ -77,7 +76,7 @@ def extract_last_date(
table_id: str,
billing_project_id: str,
var_name: str,
) -> datetime:
) -> str:
"""
Extracts the last update date of a given dataset table.
Expand All @@ -92,18 +91,20 @@ def extract_last_date(
Raises:
Exception: If an error occurs while extracting the last update date.
"""

log(f"Extracting last date from {dataset_id}.{table_id}")
query_bd = f"""
SELECT MAX({var_name}) as max_date
FROM
`{billing_project_id}.{dataset_id}.{table_id}`
"""
log(f"Query: {query_bd}")

t = bd.read_sql(
query=query_bd,
billing_project_id=billing_project_id,
from_file=True,
)
log(f"{t}")

data = t["max_date"][0]

Expand Down

0 comments on commit 882b91b

Please sign in to comment.