Airflow syntax error while edit the task file

Viewed 50

I had create the DAG with multiple task and using PostgreOperator to execute my sql task. I stored the file in the txt file and update hourly and it works just fine. However when I tried to edit the txt file (sql code save in the file) no matter what I edit the log in Airflow shows Syntax error near line 1. This happen even I just hit the enter in between the line, save the file, clear the task action and rerun it, still show syntax error.

the dag command are as follow:

dag_view1=PostgresOperator(postgres_conn_id='postgres_localhost',task_id='view1',dag=dag,autocommit=True,sql=open("/opt/airflow/dags/view/view1.txt", "r", encoding='UTF-8').read()) 

I had try to copy the same (identical) content from the original backup file and paste to the view1.txt which is the file task execute. The log on airflow still show syntax error on line 1. The content I copy are identical to the file that run normally but still failed. Any edit to the file will cause error.

Can anyone please help, Thank you!!! I am total beginner in Airflow please let me know if I have to provide further information, thanks again!

0 Answers
Related