Skip to content

Commit

Permalink
Feature to add _n alias to same column names dbt-labs#3147
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar Mittal committed Mar 11, 2021
1 parent 24e4b75 commit 33d4092
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/dbt/adapters/sql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ def process_results(
column_names: Iterable[str],
rows: Iterable[Any]
) -> List[Dict[str, Any]]:

unique_column_names = dict()
for idx in range(len(column_names)):
col_name = column_names[idx]
if col_name in unique_column_names:
unique_column_names[col_name] += 1
column_names[idx] = f'{col_name}_{unique_column_names[col_name]}'
else:
unique_column_names[column_names[idx]] = 1
return [dict(zip(column_names, row)) for row in rows]

@classmethod
Expand Down

0 comments on commit 33d4092

Please sign in to comment.