You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by su...@apache.org on 2021/03/10 22:31:52 UTC
[superset] branch dashboard-dataset-endpoint created (now 13a4e1b)
This is an automated email from the ASF dual-hosted git repository.
suddjian pushed a change to branch dashboard-dataset-endpoint
in repository https://gitbox.apache.org/repos/asf/superset.git.
at 13a4e1b finish dashboard dataset schema
This branch includes the following new commits:
new 1fc7f9f schema for dashboard datasets
new 6faba7c list instead of map
new 13a4e1b finish dashboard dataset schema
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/03: schema for dashboard datasets
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
suddjian pushed a commit to branch dashboard-dataset-endpoint
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 1fc7f9f1133f247ca68feb1a2678ea09f2e8a1f1
Author: David Aaron Suddjian <aa...@gmail.com>
AuthorDate: Wed Mar 10 13:29:31 2021 -0800
schema for dashboard datasets
---
superset/connectors/base/models.py | 1 +
superset/dashboards/schemas.py | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py
index c4cc6f4..ea96991 100644
--- a/superset/connectors/base/models.py
+++ b/superset/connectors/base/models.py
@@ -237,6 +237,7 @@ class BaseDatasource(
return {
# simple fields
"id": self.id,
+ "uid": self.uid,
"column_formats": self.column_formats,
"description": self.description,
"database": self.database.data, # pylint: disable=no-member
diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py
index bcf3b9c..cbf11e0 100644
--- a/superset/dashboards/schemas.py
+++ b/superset/dashboards/schemas.py
@@ -158,6 +158,38 @@ class DashboardGetResponseSchema(Schema):
table_names = fields.String() # legacy nonsense
+class DatabaseSchema(Schema):
+ id = fields.Int()
+ name = fields.String()
+ backend = fields.String()
+ allow_multi_schema_metadata_fetch = fields.Bool()
+ allows_subquery = fields.Bool()
+ allows_cost_estimate = fields.Bool()
+ allows_virtual_table_explore = fields.Bool()
+ explore_database_id = fields.Int()
+
+
+class DashboardDatasetSchema(Schema):
+ id = fields.Int()
+ uid = fields.Str()
+ column_formats = fields.Dict()
+ database = fields.Nested(DatabaseSchema)
+ default_endpoint = fields.String()
+ filter_select = fields.Bool()
+ filter_select_enabled = fields.Bool()
+ name = fields.Str()
+ datasource_name = fields.Str()
+ table_name = fields.Str()
+ type = fields.Str()
+ schema = fields.Str()
+ offset = fields.Int()
+ cache_timeout = fields.Int()
+ params = fields.Str()
+ perm = fields.Str()
+ edit_url = fields.Str()
+ sql = fields.Str()
+
+
class BaseDashboardSchema(Schema):
# pylint: disable=no-self-use,unused-argument
@post_load
[superset] 03/03: finish dashboard dataset schema
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
suddjian pushed a commit to branch dashboard-dataset-endpoint
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 13a4e1befbe16eb438dc3e39c938e067fc229671
Author: David Aaron Suddjian <aa...@gmail.com>
AuthorDate: Wed Mar 10 14:29:47 2021 -0800
finish dashboard dataset schema
---
superset/dashboards/api.py | 14 ++++++++++----
superset/dashboards/schemas.py | 13 +++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py
index 6565f2d..20e50e3 100644
--- a/superset/dashboards/api.py
+++ b/superset/dashboards/api.py
@@ -58,6 +58,7 @@ from superset.dashboards.filters import (
FilterRelatedRoles,
)
from superset.dashboards.schemas import (
+ DashboardDatasetSchema,
DashboardGetResponseSchema,
DashboardPostSchema,
DashboardPutSchema,
@@ -170,6 +171,7 @@ class DashboardRestApi(BaseSupersetModelRestApi):
edit_model_schema = DashboardPutSchema()
chart_entity_response_schema = ChartEntityResponseSchema()
dashboard_get_response_schema = DashboardGetResponseSchema()
+ dashboard_dataset_schema = DashboardDatasetSchema()
base_filters = [["slice", DashboardFilter, lambda: []]]
@@ -284,7 +286,9 @@ class DashboardRestApi(BaseSupersetModelRestApi):
type: object
properties:
result:
- type: object
+ type: array
+ items:
+ $ref: '#/components/schemas/DashboardDatasetSchema'
302:
description: Redirects to the current digest
400:
@@ -295,9 +299,11 @@ class DashboardRestApi(BaseSupersetModelRestApi):
$ref: '#/components/responses/404'
"""
try:
- dash = DashboardDAO.get_datasets_for_dashboard(id_or_slug)
- # result = self.datasets_response_schema.dump(dash)
- return self.response(200, result=dash)
+ datasets = DashboardDAO.get_datasets_for_dashboard(id_or_slug)
+ result = [
+ self.dashboard_dataset_schema.dump(dataset) for dataset in datasets
+ ]
+ return self.response(200, result=result)
except DashboardNotFoundError:
return self.response_404()
diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py
index cbf11e0..8664198 100644
--- a/superset/dashboards/schemas.py
+++ b/superset/dashboards/schemas.py
@@ -177,6 +177,7 @@ class DashboardDatasetSchema(Schema):
default_endpoint = fields.String()
filter_select = fields.Bool()
filter_select_enabled = fields.Bool()
+ is_sqllab_view = fields.Bool()
name = fields.Str()
datasource_name = fields.Str()
table_name = fields.Str()
@@ -188,6 +189,18 @@ class DashboardDatasetSchema(Schema):
perm = fields.Str()
edit_url = fields.Str()
sql = fields.Str()
+ select_star = fields.Str()
+ main_dttm_col = fields.Str()
+ health_check_message = fields.Str()
+ fetch_values_predicate = fields.Str()
+ template_params = fields.Str()
+ owners = fields.List(fields.Int())
+ columns = fields.List(fields.Dict())
+ metrics = fields.List(fields.Dict())
+ order_by_choices = fields.List(fields.List(fields.Str()))
+ verbose_map = fields.Dict(fields.Str(), fields.Str())
+ time_grain_sqla = fields.List(fields.List(fields.Str()))
+ granularity_sqla = fields.List(fields.List(fields.Str()))
class BaseDashboardSchema(Schema):
[superset] 02/03: list instead of map
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
suddjian pushed a commit to branch dashboard-dataset-endpoint
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 6faba7c46b0a81d544101ec712f8545efa1e623d
Author: David Aaron Suddjian <aa...@gmail.com>
AuthorDate: Wed Mar 10 13:31:11 2021 -0800
list instead of map
---
superset/dashboards/dao.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/superset/dashboards/dao.py b/superset/dashboards/dao.py
index 140bee9..0951f47 100644
--- a/superset/dashboards/dao.py
+++ b/superset/dashboards/dao.py
@@ -59,7 +59,7 @@ class DashboardDAO(BaseDAO):
return dashboard
@staticmethod
- def get_datasets_for_dashboard(id_or_slug: str) -> Dict[str, Any]:
+ def get_datasets_for_dashboard(id_or_slug: str) -> List[Any]:
query = (
db.session.query(Dashboard)
.filter(id_or_slug_filter(id_or_slug))
@@ -74,11 +74,11 @@ class DashboardDAO(BaseDAO):
if not dashboard:
raise DashboardNotFoundError()
datasource_slices = core.indexed(dashboard.slices, "datasource")
- data = {
- datasource.uid: datasource.data_for_slices(slices)
+ data = [
+ datasource.data_for_slices(slices)
for datasource, slices in datasource_slices.items()
if datasource
- }
+ ]
return data
@staticmethod