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] cluster_name = cluster_name, not cluster_id #8514

Closed
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
2 changes: 1 addition & 1 deletion superset/connectors/druid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ def query_datasources_by_name(
) -> List["DruidDatasource"]:
return (
session.query(cls)
.filter_by(cluster_name=database.id)
.filter_by(cluster_name=database.database_name)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michellethomas
This didn't cause any problems for us because we use our own security manager, so this function isn't used.

I did a little more digging, and I'm not entirely certain that cluster_name=database.database_name is correct, since clusters != databases in our tables. Maybe this line should just be removed? Do you know anyone with more context on this kind of thing? Either way, this change won't cause any (more) problems, but it does seem wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe @mistercrunch could chime in here? This code is pretty old

Copy link
Member

Choose a reason for hiding this comment

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

Mmmh, for reference, this came from #2497.

Clearly there are issues around the Connector interface. Good news is we're planning on deprecating the Druid connector in favor of SQLAlchemy

Copy link
Member

Choose a reason for hiding this comment

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

This new line is likely to fail as much as the previous line.

.filter_by(datasource_name=datasource_name)
.all()
)
Expand Down
2 changes: 1 addition & 1 deletion superset/connectors/druid/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def pre_add(self, datasource):
with db.session.no_autoflush:
query = db.session.query(models.DruidDatasource).filter(
models.DruidDatasource.datasource_name == datasource.datasource_name,
models.DruidDatasource.cluster_name == datasource.cluster.id,
models.DruidDatasource.cluster_name == datasource.cluster.cluster_name,
)
if db.session.query(query.exists()).scalar():
raise Exception(get_datasource_exist_error_msg(datasource.full_name))
Expand Down