Skip to content

More descriptive error when trying to create a partitioned table #1329

@radumas

Description

@radumas

log

[2026-01-15 10:56:22] ERROR - Non-audited tables do not use the primary key. source=gis.gccview.gcc_puller_functions loc=gcc_puller_functions.py:652
[2026-01-15 10:58:12] INFO - Map index rendered as property_boundary source=task loc=task_runner.py:1341
[2026-01-15 10:58:12] ERROR - Task failed with exception source=task loc=task_runner.py:1008
UndefinedTable: relation "gis.property_boundary" does not exist
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 934 in run
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1325 in _execute_task
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/sdk/bases/operator.py", line 417 in wrapper
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/sdk/bases/decorator.py", line 252 in execute
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/sdk/bases/operator.py", line 417 in wrapper
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/providers/standard/operators/python.py", line 214 in execute
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/providers/standard/operators/python.py", line 237 in execute_callable
File "/home/airflow/airflow_venv/lib64/python3.12/site-packages/airflow/sdk/execution_time/callback_runner.py", line 82 in run
File "/home/airflow/airflow/dags/gcc_layers_pull.py", line 109 in pull_layer
File "/home/airflow/bdit_repos/bdit_data-sources/_/gis/gccview/gcc_puller_functions.py", line 659 in get_layer
File "/home/airflow/bdit_repos/bdit_data-sources/_/gis/gccview/gcc_puller_functions.py", line 214 in create_partitioned_table

First error is not fatal. Just logged.

[2026-01-15 10:56:22] ERROR - Non-audited tables do not use the primary key. source=gis.gccview.gcc_puller_functions loc=gcc_puller_functions.py:652

#--------------------------------
if is_audited and primary_key is None:
LOGGER.error("Audited tables should have a primary key.")
if not(is_audited) and primary_key is not None:
LOGGER.error("Non-audited tables do not use the primary key.")
#--------------------------------

The fatal error is UndefinedTable: relation "gis.property_boundary" does not exist and it comes from

with con:
with con.cursor() as cur:
yr_partition_sql = sql.SQL(
"CREATE TABLE IF NOT EXISTS {schema_child_table} PARTITION OF {schema_parent_table} FOR VALUES FROM (%s) TO (%s) PARTITION BY LIST (version_date);"
).format(
schema_child_table = sql.Identifier(schema_name, output_table_with_yr),
schema_parent_table = sql.Identifier(schema_name, output_table)
)
cur.execute(yr_partition_sql, (yr_partition_start.to_date_string(), yr_partition_end.to_date_string()))

There should be some check for the existence of the parent table before creating, and a logged error explaining what's up. More involved solution would be automatically creating parent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions