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

feat(explore): allow opening charts with missing dataset #12705

Merged
merged 4 commits into from
Jan 25, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix tests
ktmud committed Jan 25, 2021

Verified

This commit was signed with the committer’s verified signature.
Kikobeats Kiko Beats
commit 3c5ab2fed1a87f208958f115f044c82f2f7c004c
4 changes: 2 additions & 2 deletions superset/connectors/druid/views.py
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@
BaseSupersetView,
DatasourceFilter,
DeleteMixin,
get_datasource_exist_error_msg,
get_dataset_exist_error_msg,
ListWidgetWithCheckboxes,
SupersetModelView,
validate_json,
@@ -352,7 +352,7 @@ def pre_add(self, item: "DruidDatasourceModelView") -> None:
models.DruidDatasource.cluster_id == item.cluster_id,
)
if db.session.query(query.exists()).scalar():
raise Exception(get_datasource_exist_error_msg(item.full_name))
raise Exception(get_dataset_exist_error_msg(item.full_name))

def post_add(self, item: "DruidDatasourceModelView") -> None:
item.refresh_metrics()
1 change: 1 addition & 0 deletions superset/datasets/api.py
Original file line number Diff line number Diff line change
@@ -231,6 +231,7 @@ def post(self) -> Response:
# This validates custom Schema with custom validations
except ValidationError as error:
return self.response_400(message=error.messages)

try:
new_model = CreateDatasetCommand(g.user, item).run()
return self.response(201, id=new_model.id, result=item)
6 changes: 3 additions & 3 deletions superset/datasets/commands/exceptions.py
Original file line number Diff line number Diff line change
@@ -28,8 +28,8 @@
)


def get_datasource_exist_error_msg(full_name: str) -> str:
return _("Datasource %(name)s already exists", name=full_name)
def get_dataset_exist_error_msg(full_name: str) -> str:
return _("Dataset %(name)s already exists", name=full_name)


class DatabaseNotFoundValidationError(ValidationError):
@@ -57,7 +57,7 @@ class DatasetExistsValidationError(ValidationError):

def __init__(self, table_name: str) -> None:
super().__init__(
get_datasource_exist_error_msg(table_name), field_name="table_name"
[get_dataset_exist_error_msg(table_name)], field_name="table_name"
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch 👍

)


2 changes: 1 addition & 1 deletion superset/models/slice.py
Original file line number Diff line number Diff line change
@@ -206,7 +206,7 @@ def digest(self) -> str:
"""
Returns a MD5 HEX digest that makes this dashboard unique
"""
return utils.md5_hex(self.params)
return utils.md5_hex(self.params or "")
Copy link
Member

Choose a reason for hiding this comment

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

Not that it matters, but I've always been allergic to md5 on empty string:

>>> import hashlib
>>> hashlib.md5(''.encode()).hexdigest()
'd41d8cd98f00b204e9800998ecf8427e'
Suggested change
return utils.md5_hex(self.params or "")
return utils.md5_hex(self.params) if self.params else ''

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'll return None here just to be more explicit. The original change is for avoiding an uncaught exception, explicitly returning None forces the downstream handle the case of missing params more properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nvm. I'll keep utils.md5_hex(self.params or "") since this key is also used in thumbnail URLs:

        return f"/api/v1/chart/{self.id}/thumbnail/{self.digest}/"

We can make a follow up PR to rename digest to thumbnail_key (for both chart and dashboard) if we think it's necessary.


@property
def thumbnail_url(self) -> str:
4 changes: 2 additions & 2 deletions superset/translations/de/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@
"Charts could not be deleted.": [""],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": [""],
"Datasource does not exist": ["Datenquellen"],
"Dataset does not exist": ["Datenquellen"],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": ["Druid Datenquelle einfügen"],
@@ -643,7 +643,7 @@
"Add Annotation Layer": ["Anmerkungstufe"],
"Edit Annotation Layer": ["Anmerkungstufe"],
"Name": ["Name"],
"Datasource %(name)s already exists": [""],
"Dataset %(name)s already exists": [""],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
""
],
4 changes: 2 additions & 2 deletions superset/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -776,7 +776,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr "Datenquellen"

#: superset/common/query_object.py:301
@@ -2303,7 +2303,7 @@ msgstr "Name"

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr ""

#: superset/views/base.py:227
4 changes: 2 additions & 2 deletions superset/translations/en/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -200,7 +200,7 @@
"Charts could not be deleted.": [""],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": [""],
"Datasource does not exist": [""],
"Dataset does not exist": [""],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": [""],
@@ -585,7 +585,7 @@
"Add Annotation Layer": [""],
"Edit Annotation Layer": [""],
"Name": [""],
"Datasource %(name)s already exists": [""],
"Dataset %(name)s already exists": [""],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
""
],
4 changes: 2 additions & 2 deletions superset/translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -775,7 +775,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr ""

#: superset/common/query_object.py:301
@@ -2302,7 +2302,7 @@ msgstr ""

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr ""

#: superset/views/base.py:227
4 changes: 2 additions & 2 deletions superset/translations/es/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -272,7 +272,7 @@
"Charts could not be deleted.": ["Los Gráficos no han podido eliminarse"],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": ["Los propietarios son invalidos"],
"Datasource does not exist": ["La fuente no existe"],
"Dataset does not exist": ["La fuente no existe"],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": ["Añadiendo [{}] como nueva fuente"],
@@ -696,7 +696,7 @@
"Add Annotation Layer": [""],
"Edit Annotation Layer": [""],
"Name": ["Nombre"],
"Datasource %(name)s already exists": [
"Dataset %(name)s already exists": [
"La fuente de datos %(name)s ya existe"
],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
4 changes: 2 additions & 2 deletions superset/translations/es/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -784,7 +784,7 @@ msgid "Owners are invalid"
msgstr "Los propietarios son invalidos"

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr "La fuente no existe"

#: superset/common/query_object.py:301
@@ -2336,7 +2336,7 @@ msgstr "Nombre"

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr "La fuente de datos %(name)s ya existe"

#: superset/views/base.py:227
6 changes: 2 additions & 4 deletions superset/translations/fr/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -277,9 +277,7 @@
"Charts could not be deleted.": ["La requête ne peut pas être chargée"],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": [""],
"Datasource does not exist": [
"La source de données %(name)s existe déjà"
],
"Dataset does not exist": ["La source de données %(name)s existe déjà"],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": ["Ajouter une source de données Druid"],
@@ -728,7 +726,7 @@
"Add Annotation Layer": ["Ajouter une couche d'annotation"],
"Edit Annotation Layer": ["Ajouter une couche d'annotation"],
"Name": ["Nom"],
"Datasource %(name)s already exists": [
"Dataset %(name)s already exists": [
"La source de données %(name)s existe déjà"
],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
4 changes: 2 additions & 2 deletions superset/translations/fr/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -781,7 +781,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr "La source de données %(name)s existe déjà"

#: superset/common/query_object.py:301
@@ -2350,7 +2350,7 @@ msgstr "Nom"

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr "La source de données %(name)s existe déjà"

#: superset/views/base.py:227
4 changes: 2 additions & 2 deletions superset/translations/it/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -237,7 +237,7 @@
"Charts could not be deleted.": ["La query non può essere caricata"],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": [""],
"Datasource does not exist": ["Sorgente dati e tipo di grafico"],
"Dataset does not exist": ["Sorgente dati e tipo di grafico"],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": [""],
@@ -643,7 +643,7 @@
"Add Annotation Layer": [""],
"Edit Annotation Layer": [""],
"Name": ["Nome"],
"Datasource %(name)s already exists": [""],
"Dataset %(name)s already exists": [""],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
""
],
4 changes: 2 additions & 2 deletions superset/translations/it/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -773,7 +773,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr "Sorgente dati e tipo di grafico"

#: superset/common/query_object.py:301
@@ -2331,7 +2331,7 @@ msgstr "Nome"

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr ""

#: superset/views/base.py:227
4 changes: 2 additions & 2 deletions superset/translations/ja/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@
"Charts could not be deleted.": [""],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": [""],
"Datasource does not exist": ["データソース"],
"Dataset does not exist": ["データソース"],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": [""],
@@ -601,7 +601,7 @@
"Add Annotation Layer": [""],
"Edit Annotation Layer": [""],
"Name": ["名前"],
"Datasource %(name)s already exists": [""],
"Dataset %(name)s already exists": [""],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
""
],
4 changes: 2 additions & 2 deletions superset/translations/ja/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -772,7 +772,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr "データソース"

#: superset/common/query_object.py:301
@@ -2294,7 +2294,7 @@ msgstr "名前"

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr ""

#: superset/views/base.py:227
4 changes: 2 additions & 2 deletions superset/translations/ko/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@
"Charts could not be deleted.": [""],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": [""],
"Datasource does not exist": ["데이터소스"],
"Dataset does not exist": ["데이터소스"],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": ["새 데이터소스 스캔"],
@@ -579,7 +579,7 @@
"Add Annotation Layer": [""],
"Edit Annotation Layer": ["주석 레이어"],
"Name": ["이름"],
"Datasource %(name)s already exists": [""],
"Dataset %(name)s already exists": [""],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
""
],
4 changes: 2 additions & 2 deletions superset/translations/ko/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -772,7 +772,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr "데이터소스"

#: superset/common/query_object.py:301
@@ -2294,7 +2294,7 @@ msgstr "이름"

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr ""

#: superset/views/base.py:227
4 changes: 2 additions & 2 deletions superset/translations/messages.pot
Original file line number Diff line number Diff line change
@@ -775,7 +775,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr ""

#: superset/common/query_object.py:301
@@ -2306,7 +2306,7 @@ msgstr ""

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr ""

#: superset/views/base.py:227
6 changes: 2 additions & 4 deletions superset/translations/pt/LC_MESSAGES/message.json
Original file line number Diff line number Diff line change
@@ -258,7 +258,7 @@
"Charts could not be deleted.": ["Não foi possível carregar a query"],
"Import chart failed for an unknown reason": [""],
"Owners are invalid": [""],
"Datasource does not exist": ["Origem de dados %(name)s já existe"],
"Dataset does not exist": ["Origem de dados %(name)s já existe"],
"`operation` property of post processing object undefined": [""],
"Unsupported post processing operation: %(operation)s": [""],
"Adding new datasource [{}]": ["Adicionar origem de dados Druid"],
@@ -693,9 +693,7 @@
"Add Annotation Layer": ["Camadas de anotação"],
"Edit Annotation Layer": ["Camadas de anotação"],
"Name": ["Nome"],
"Datasource %(name)s already exists": [
"Origem de dados %(name)s já existe"
],
"Dataset %(name)s already exists": ["Origem de dados %(name)s já existe"],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
"Tabela [{}] não encontrada, por favor verifique conexão à base de dados, esquema e nome da tabela"
],
4 changes: 2 additions & 2 deletions superset/translations/pt/LC_MESSAGES/message.po
Original file line number Diff line number Diff line change
@@ -783,7 +783,7 @@ msgid "Owners are invalid"
msgstr ""

#: superset/commands/exceptions.py:92
msgid "Datasource does not exist"
msgid "Dataset does not exist"
msgstr "Origem de dados %(name)s já existe"

#: superset/common/query_object.py:297
@@ -2363,7 +2363,7 @@ msgstr "Nome"

#: superset/views/base.py:207
#, python-format
msgid "Datasource %(name)s already exists"
msgid "Dataset %(name)s already exists"
msgstr "Origem de dados %(name)s já existe"

#: superset/views/base.py:227
4 changes: 1 addition & 3 deletions superset/translations/pt/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -1150,9 +1150,7 @@
"Welcome!": ["Bem vindo!"],
"Test Connection": ["Conexão de teste"],
"Manage": ["Gerir"],
"Datasource %(name)s already exists": [
"Origem de dados %(name)s já existe"
],
"Dataset %(name)s already exists": ["Origem de dados %(name)s já existe"],
"json isn't valid": ["json não é válido"],
"Delete": ["Eliminar"],
"Delete all Really?": ["Tem a certeza que pretende eliminar tudo?"],
6 changes: 2 additions & 4 deletions superset/translations/pt_BR/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
@@ -328,7 +328,7 @@
"A importação do gráfico falhou por um motivo desconhecido"
],
"Owners are invalid": ["Donos inválidos"],
"Datasource does not exist": ["Fonte de dados não existe"],
"Dataset does not exist": ["Fonte de dados não existe"],
"`operation` property of post processing object undefined": [
"A propriedade `operation` do objeto de pós processamento está indefinida"
],
@@ -935,9 +935,7 @@
"Add Annotation Layer": ["Adicionar camada de anotação"],
"Edit Annotation Layer": ["Editar camada de anotação"],
"Name": ["Nome"],
"Datasource %(name)s already exists": [
"Fonte de dados %(name)s já existe"
],
"Dataset %(name)s already exists": ["Fonte de dados %(name)s já existe"],
"Table [%{table}s] could not be found, please double check your database connection, schema, and table name, error: {}": [
"Não foi possível localizar a tabela [%{table}s], por favor revise sua conexão com o banco de dados, esquema e nome da tabela. Erro: {}"
],
Loading