Skip to content

Commit

Permalink
Add prompt, response, and messages to Firestore -> Snowflake DAG
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaneve authored Apr 3, 2024
1 parent e8ee422 commit b1f3a90
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions airflow/dags/metrcis/load_firestore_to_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def load_request_data_from_firestore() -> list[tuple[str, int, bool, int]]:
status = doc_dict.get("status") == "complete"
sent_at = datetime.fromtimestamp(doc_dict.get("sent_at"))
client = doc_dict.get("client")
rows.append((uuid, score, status, sent_at, client))
prompt = doc_dict.get("prompt")
response = doc_dict.get("response")
messages = doc_dict.get("messages")
rows.append((uuid, score, status, sent_at, client, prompt, response, messages))

return rows

Expand All @@ -78,9 +81,9 @@ def write_request_data_to_snowflake(rows: list[tuple[str, int, bool, int]]) -> N

insert_sql = f"""
INSERT INTO
{METRICS_SNOWFLAKE_DB_DATABASE}.{METRICS_SNOWFLAKE_DB_SCHEMA}.request(uuid, score, success, created_at, client)
{METRICS_SNOWFLAKE_DB_DATABASE}.{METRICS_SNOWFLAKE_DB_SCHEMA}.request(uuid, score, success, created_at, client, prompt, response, messages)
VALUES
(?, ?, ?, ?, ?)
(?, ?, ?, ?, ?, ?, ?, ?)
"""
conn.cursor().executemany(insert_sql, rows)

Expand Down

0 comments on commit b1f3a90

Please sign in to comment.