• 카테고리

    질문 & 답변
  • 세부 분야

    데이터 엔지니어링

  • 해결 여부

    미해결

airflow tasks test error

23.09.07 11:00 작성 조회수 359

2

 

안녕하세요.

강의 실습중에 'airflow tasks test postgres_loader execute_sql_query 2023-01-01 ' 터미널에서 실행후 아래와 같은 오류가 발생해서 여쭤보고자 질문드립니다.

Error 본문

DB 연결 정보

DB Table 생성 정보

Airflow UI

실행 환경

Mac 14 pro

Python 3.11.5

pip freeze

aiohttp==3.8.5
aiosignal==1.3.1
alembic==1.11.3
anyio==3.7.1
apache-airflow==2.7.0
apache-airflow-providers-common-sql==1.7.0
apache-airflow-providers-ftp==3.5.0
apache-airflow-providers-http==4.5.0
apache-airflow-providers-imap==3.3.0
apache-airflow-providers-postgres==5.6.0
apache-airflow-providers-sqlite==3.4.3
apispec==6.3.0
argcomplete==3.1.1
asgiref==3.7.2
async-timeout==4.0.3
attrs==23.1.0
autobahn==23.1.2
Automat==22.10.0
Babel==2.12.1
backoff==1.10.0
blinker==1.6.2
cachelib==0.9.0
cachetools==5.3.1
cattrs==23.1.2
certifi==2023.7.22
cffi==1.15.1
channels==4.0.0
charset-normalizer==3.2.0
click==8.1.7
clickclick==20.10.2
colorama==0.4.6
colorlog==4.8.0
ConfigUpdater==3.1.1
connexion==2.14.2
constantly==15.1.0
cron-descriptor==1.4.0
croniter==1.4.1
cryptography==41.0.3
daphne==4.0.0
Deprecated==1.2.14
dill==0.3.1.1
distlib==0.3.5
Django==4.1.4
djangorestframework==3.11.2
dnspython==2.4.2
docutils==0.20.1
email-validator==1.3.1
exceptiongroup==1.1.3
filelock==3.8.0
Flask==2.2.5
Flask-AppBuilder==4.3.3
Flask-Babel==2.0.0
Flask-Caching==2.0.2
Flask-JWT-Extended==4.5.2
Flask-Limiter==3.3.1
Flask-Login==0.6.2
Flask-Session==0.5.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.1.1
frozenlist==1.4.0
google-auth==2.22.0
google-re2==1.1
googleapis-common-protos==1.60.0
graphviz==0.20.1
grpcio==1.57.0
gunicorn==21.2.0
h11==0.14.0
httpcore==0.16.3
httpx==0.23.3
hyperlink==21.0.0
idna==3.4
importlib-resources==6.0.1
incremental==22.10.0
inflection==0.5.1
itsdangerous==2.1.2
Jinja2==3.1.2
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
kubernetes==27.2.0
lazy-object-proxy==1.9.0
limits==3.5.0
linkify-it-py==2.0.2
lockfile==0.12.2
Mako==1.2.4
Markdown==3.4.4
markdown-it-py==3.0.0
MarkupSafe==2.1.3
marshmallow==3.20.1
marshmallow-oneofschema==3.0.1
marshmallow-sqlalchemy==0.26.1
mdit-py-plugins==0.4.0
mdurl==0.1.2
multidict==6.0.4
oauthlib==3.2.2
opentelemetry-api==1.15.0
opentelemetry-exporter-otlp==1.15.0
opentelemetry-exporter-otlp-proto-grpc==1.15.0
opentelemetry-exporter-otlp-proto-http==1.15.0
opentelemetry-proto==1.15.0
opentelemetry-sdk==1.15.0
opentelemetry-semantic-conventions==0.36b0
ordered-set==4.1.0
packaging==23.1
pathspec==0.11.2
pendulum==2.1.2
platformdirs==2.5.2
pluggy==1.2.0
prison==0.2.1
protobuf==4.21.12
psutil==5.9.5
psycopg2-binary==2.9.7
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pydantic==1.10.12
Pygments==2.16.1
PyJWT==2.8.0
pyOpenSSL==23.0.0
python-daemon==3.0.1
python-dateutil==2.8.2
python-nvd3==0.15.0
python-slugify==8.0.1
pytz==2023.3
pytzdata==2020.1
PyYAML==6.0.1
referencing==0.30.2
requests==2.31.0
requests-oauthlib==1.3.1
requests-toolbelt==1.0.0
rfc3339-validator==0.1.4
rfc3986==1.5.0
rich==13.5.2
rich-argparse==1.2.0
rpds-py==0.9.2
rsa==4.9
service-identity==21.1.0
setproctitle==1.3.2
six==1.16.0
sniffio==1.3.0
SQLAlchemy==1.4.49
SQLAlchemy-JSONField==1.0.1.post0
SQLAlchemy-Utils==0.41.1
sqlparse==0.4.4
tabulate==0.9.0
tenacity==8.2.3
termcolor==2.3.0
text-unidecode==1.3
Twisted==22.10.0
txaio==23.1.1
typing_extensions==4.7.1
uc-micro-py==1.0.2
unicodecsv==0.14.1
urllib3==1.26.16
virtualenv==20.16.3
websocket-client==1.6.2
Werkzeug==2.2.3
wrapt==1.15.0
WTForms==3.0.1
yarl==1.9.2
zope.interface==5.5.2

제가 생각하는 에러 원인

오류 본문을 보고 DB 연결 문제라 생각이 들어 DB를 재생성 하여지만 아직도 원인은 똑같았습니다.

 

제가 작성한 코드는 아래 github에 올렸습니다.

https://github.com/saohwan/learn-airflow

답변 1

답변을 작성해보세요.

0

안녕하세요 Cooper Ben님,

저도 확실한 건 찾기가 어려운데, 혹시 https://github.com/saohwan/learn-airflow/blob/238ee299f725e84cf61ea590cc641b8973c8eca6/dags/postgres_loader.py#L25C56-L25C78 요기 부분 my_postgres_connection UI로 잘 저장하셨나요?

그게 잘 되어있다면 insert 쿼리가 아닌 SELECT COUNT(*) FROM sample_table 쿼리를 한번 넣어 보시겠어요?

그것도 안된다면 뭔가 확실히 커넥션에 문제가 있는 듯합니다.

또 다른 디버깅 순서는 그냥 간단한거 시작하는 겁니다. 포스트 그레스 부분 빼고

task1 = PythonOperator(task_id='print_hello_task',
                           python_callable=print_hello,
                           dag=dag)

요런거 되나 해보시고... 그게 된다면 확실히 PostgresOperator 이게 잘 못 되었겠죠

apache-airflow==2.6.2
apache-airflow-providers-http==4.4.1
apache-airflow-providers-postgres==5.5.2

요 버전으로 설치해서 해보시겠어요?

그럼 도움이 되었길 바라겠습니다.

Cooper Ben님의 프로필

Cooper Ben

질문자

2023.09.07

해결하였습니다!!!! ㅜㅜ

문제 원인은 my_postgres_connection UI로 잘 저장 답변을 자세히 살펴보고 강의로 다시 확인해보니 UI connection 저장 강의 부분을 제가 놓쳤습니다...

 

감사합니다 🔥

축하드립니다 ㅎㅎㅎ 이제 그 부분은 절대로 잊지 않으시겠네요 ㅎㅎ