mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
fix: dataset extra import/export (#17740)
* fix: dataset extra import/export * Update superset/datasets/commands/importers/v1/utils.py
This commit is contained in:
@@ -98,7 +98,8 @@ template_params:
|
||||
answer: '42'
|
||||
filter_select_enabled: 1
|
||||
fetch_values_predicate: foo IN (1, 2)
|
||||
extra: '{{\"warning_markdown\": \"*WARNING*\"}}'
|
||||
extra:
|
||||
warning_markdown: '*WARNING*'
|
||||
uuid: null
|
||||
metrics:
|
||||
- metric_name: cnt
|
||||
|
||||
@@ -22,6 +22,8 @@ from typing import Any, Dict
|
||||
|
||||
from sqlalchemy.orm.session import Session
|
||||
|
||||
from superset.datasets.schemas import ImportV1DatasetSchema
|
||||
|
||||
|
||||
def test_import_(app_context: None, session: Session) -> None:
|
||||
"""
|
||||
@@ -56,7 +58,7 @@ def test_import_(app_context: None, session: Session) -> None:
|
||||
"template_params": {"answer": "42",},
|
||||
"filter_select_enabled": True,
|
||||
"fetch_values_predicate": "foo IN (1, 2)",
|
||||
"extra": '{"warning_markdown": "*WARNING*"}',
|
||||
"extra": {"warning_markdown": "*WARNING*"},
|
||||
"uuid": dataset_uuid,
|
||||
"metrics": [
|
||||
{
|
||||
@@ -147,7 +149,8 @@ def test_import_column_extra_is_string(app_context: None, session: Session) -> N
|
||||
session.flush()
|
||||
|
||||
dataset_uuid = uuid.uuid4()
|
||||
config: Dict[str, Any] = {
|
||||
yaml_config: Dict[str, Any] = {
|
||||
"version": "1.0.0",
|
||||
"table_name": "my_table",
|
||||
"main_dttm_col": "ds",
|
||||
"description": "This is the description",
|
||||
@@ -171,11 +174,11 @@ def test_import_column_extra_is_string(app_context: None, session: Session) -> N
|
||||
{
|
||||
"column_name": "profit",
|
||||
"verbose_name": None,
|
||||
"is_dttm": None,
|
||||
"is_active": None,
|
||||
"is_dttm": False,
|
||||
"is_active": True,
|
||||
"type": "INTEGER",
|
||||
"groupby": None,
|
||||
"filterable": None,
|
||||
"groupby": False,
|
||||
"filterable": False,
|
||||
"expression": "revenue-expenses",
|
||||
"description": None,
|
||||
"python_date_format": None,
|
||||
@@ -183,8 +186,12 @@ def test_import_column_extra_is_string(app_context: None, session: Session) -> N
|
||||
}
|
||||
],
|
||||
"database_uuid": database.uuid,
|
||||
"database_id": database.id,
|
||||
}
|
||||
|
||||
sqla_table = import_dataset(session, config)
|
||||
schema = ImportV1DatasetSchema()
|
||||
dataset_config = schema.load(yaml_config)
|
||||
dataset_config["database_id"] = database.id
|
||||
sqla_table = import_dataset(session, dataset_config)
|
||||
|
||||
assert sqla_table.columns[0].extra == '{"certified_by": "User"}'
|
||||
assert sqla_table.extra == '{"warning_markdown": "*WARNING*"}'
|
||||
|
||||
Reference in New Issue
Block a user