Skip to content

Commit

Permalink
Merge pull request #699 from ccao-data/print-updated-columns
Browse files Browse the repository at this point in the history
Ensure socrata workflow inputs are handled correctly
  • Loading branch information
wrridgeway authored Jan 9, 2025
2 parents 289226e + c9ef687 commit 607e38a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions socrata/socrata_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def build_query(
+ columns[columns["type"] == "array(varchar)"]["column"]
)

print(f"The following columns will be updated: {columns}")

query = f"SELECT {row_identifier}, {', '.join(columns['column'])} FROM {athena_asset}"

if not years:
Expand Down Expand Up @@ -204,7 +206,7 @@ def generate_groups(athena_asset, years=None, by_township=False):
if not years and by_township:
raise ValueError("Cannot set 'by_township' when 'years' is None")

if years == "all":
if years == ["all"]:
years = (
cursor.execute(
"SELECT DISTINCT year FROM " + athena_asset + " ORDER BY year"
Expand All @@ -213,6 +215,8 @@ def generate_groups(athena_asset, years=None, by_township=False):
.to_list()
)

# Ensure township codes aren't available if they shouldn't be
township_codes = []
if by_township:
township_codes = (
cursor.execute(
Expand Down Expand Up @@ -333,6 +337,6 @@ def socrata_upload(
socrata_upload(
socrata_asset=os.getenv("SOCRATA_ASSET"),
overwrite=os.getenv("OVERWRITE"),
years=str(os.getenv("YEARS")).split(","),
years=str(os.getenv("YEARS")).replace(" ", "").split(","),
by_township=os.getenv("BY_TOWNSHIP"),
)

0 comments on commit 607e38a

Please sign in to comment.