drobert commented on a change in pull request #19053:
URL: https://github.com/apache/airflow/pull/19053#discussion_r732092369
##########
File path: docs/apache-airflow/tutorial.rst
##########
@@ -410,23 +431,25 @@ Let's break this down into 2 steps: get data & merge data:
@task
def get_data():
+ # NOTE: configure this as appropriate for your airflow environment
data_path = "/usr/local/airflow/dags/files/employees.csv"
url =
"https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/pipeline_example.csv"
- response = requests.request("GET", url)
-
- with open(data_path, "w") as file:
- for row in response.text.split("\n"):
- if row:
- file.write(row + "\n")
+ with requests.get(url, stream=True) as req:
Review comment:
Streams the content now instead of loading into memory and splitting by
line (then re-adding lines)
##########
File path: docs/apache-airflow/tutorial.rst
##########
@@ -446,13 +469,14 @@ Here we are passing a ``GET`` request to get the data
from the URL and save it i
from "Employees_temp";
"""
try:
- postgres_hook = PostgresHook(postgres_conn_id="LOCAL")
+ postgres_hook = PostgresHook(postgres_conn_id=conn_id)
conn = postgres_hook.get_conn()
cur = conn.cursor()
cur.execute(query)
conn.commit()
return 0
except Exception as e:
+ logging.error(f"Failed to merge data: {e}")
Review comment:
Added some logging
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]