From aea54064e6c21282d2e6730808f645ab21baab8d Mon Sep 17 00:00:00 2001 From: Rishabh Srivastava Date: Thu, 16 May 2024 19:44:23 +0530 Subject: [PATCH] de-duplicate colnames if they are identical --- defog/query.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/defog/query.py b/defog/query.py index 20b5e30..da34e32 100644 --- a/defog/query.py +++ b/defog/query.py @@ -43,6 +43,10 @@ def execute_query_once(db_type: str, db_creds, query: str): cur.execute(query) colnames = [desc[0] for desc in cur.description] + + # if there are any column names that are the same, we need to deduplicate them + colnames = [f"{col}_{i}" if colnames.count(col) > 1 else col for i, col in enumerate(colnames)] + results = cur.fetchall() cur.close() conn.close()