Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertica: prevent overwriting row data when duplicated column names exist #4201

Merged
merged 3 commits into from
Oct 2, 2019

Conversation

rz269
Copy link
Contributor

@rz269 rz269 commented Sep 30, 2019

This pull request fixes issues with duplicated column names for Vertica query runner.

fetch_columns method is used for this fix.

Problem Description:
If we have columns with the same name in the select statement then the query result is overridden by the value of first column. e.g.
select count(*) , count(distinct user_id) , count(user_id) from example_table

Example:
Duplicated column names -- 2nd and 3rd columns' values were overwritten by the 1st column:
vertica_dup_column_name
A simple fix is to give each column a unique name:
vertica_dup_column_name2

@arikfr arikfr merged commit f6ad3d9 into getredash:master Oct 2, 2019
@arikfr
Copy link
Member

arikfr commented Oct 2, 2019

Thanks 👍

'type': types_map.get(col[1], None)} for col in columns_data]
columns_data = [(i[0], types_map.get(i[1], None)) for i in cursor.description]

columns = self.fetch_columns(column_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I stumbled upon this commit while rebasing my work on master.
Tell me if I'm missing something but it looks like column_data is not defined anywhere. Shouldn't it be columns_data?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😳 of course you're right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants