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

[fix] handle null column_name in druid/sqla models #7063

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions superset/connectors/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def uid(self):

@property
def column_names(self):
return sorted([c.column_name for c in self.columns])
return sorted([c.column_name for c in self.columns], key=lambda x: x or '')

@property
def columns_types(self):
Expand Down Expand Up @@ -166,7 +166,9 @@ def select_star(self):
def data(self):
"""Data representation of the datasource sent to the frontend"""
order_by_choices = []
for s in sorted(self.column_names):
# self.column_names return sorted column_names
for s in self.column_names:
s = str(s or '')
Copy link
Member

Choose a reason for hiding this comment

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

I think your investigation surfaced that the are columns without a name which seems bad. I can look into why there are columns without names and produce a migration if needed.

I'm a little perplexed what order_by_choices means for empty strings and how this is used.

order_by_choices.append((json.dumps([s, True]), s + ' [asc]'))
order_by_choices.append((json.dumps([s, False]), s + ' [desc]'))

Expand Down
2 changes: 1 addition & 1 deletion superset/connectors/druid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class DruidColumn(Model, BaseColumn):
export_parent = 'datasource'

def __repr__(self):
return self.column_name
return self.column_name or str(self.id)

@property
def expression(self):
Expand Down