Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_file replacing existing tables fails if there are views on the tables #1929

Open
mpgreg opened this issue May 8, 2023 · 1 comment
Open
Labels
bug Something isn't working
Milestone

Comments

@mpgreg
Copy link

mpgreg commented May 8, 2023

load_file(if_exists='replace') works the first time a DAG is run. Upstream tasks subsequently create views on that DAG. Rerunning the DAG fails as it cannot drop the existing tables because of the dependent views.

[2023-04-30, 09:32:12 UTC] {taskinstance.py:1776} ERROR - Task failed with exception
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.DependentObjectsStillExist: cannot drop table tmp_astro.stg_customers because other objects depend on it
DETAIL: view tmp_astro.customers depends on table tmp_astro.stg_customers
HINT: Use DROP ... CASCADE to drop the dependent objects too.

Version

  • Astro: 1.5.3
  • OS: quay.io/astronomer/astro-runtime:7.4.2-base

To Reproduce

Example DAG is at:
https://github.com/astronomer/airflow-ml-demo/blob/c2e150649301458ef4fe26d8b6bd6c3f30836137/dags/customer_analytics.py#L197

Upstream tasks that create views are at:
https://github.com/astronomer/airflow-ml-demo/blob/c2e150649301458ef4fe26d8b6bd6c3f30836137/dags/customer_analytics.py#L239

Expected behavior
if_exists='replace' should drop the table even if views exist

@tatiana tatiana added the bug Something isn't working label May 9, 2023
@tatiana tatiana added this to the 1.7.0 milestone May 9, 2023
@tatiana
Copy link
Collaborator

tatiana commented May 9, 2023

Thanks for reporting the issue, @mpgreg ! I added it to the 1.7 milestone.
cc @jlaneve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants