mirror of
https://github.com/apache/superset.git
synced 2026-04-07 10:31:50 +00:00
feat: Add owners and physical/virtual status to Datasets API list endpoint (#10025)
* Add owners and physical/virtual status to Datasets API list endpoint * black * Update type definition for DatasourceKind Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> * Fixin' tests and mypy Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,6 +23,7 @@
|
|||||||
.bento*
|
.bento*
|
||||||
.cache-loader
|
.cache-loader
|
||||||
.coverage
|
.coverage
|
||||||
|
cover
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.eggs
|
.eggs
|
||||||
.envrc
|
.envrc
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import json
|
import json
|
||||||
|
from enum import Enum
|
||||||
from typing import Any, Dict, Hashable, List, Optional, Type, Union
|
from typing import Any, Dict, Hashable, List, Optional, Type, Union
|
||||||
|
|
||||||
from flask_appbuilder.security.sqla.models import User
|
from flask_appbuilder.security.sqla.models import User
|
||||||
@@ -51,6 +52,11 @@ COLUMN_FORM_DATA_PARAMS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class DatasourceKind(str, Enum):
|
||||||
|
VIRTUAL = "virtual"
|
||||||
|
PHYSICAL = "physical"
|
||||||
|
|
||||||
|
|
||||||
class BaseDatasource(
|
class BaseDatasource(
|
||||||
AuditMixinNullable, ImportMixin
|
AuditMixinNullable, ImportMixin
|
||||||
): # pylint: disable=too-many-public-methods
|
): # pylint: disable=too-many-public-methods
|
||||||
@@ -101,6 +107,13 @@ class BaseDatasource(
|
|||||||
owners: List[User]
|
owners: List[User]
|
||||||
update_from_object_fields: List[str]
|
update_from_object_fields: List[str]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def kind(self) -> str:
|
||||||
|
if self.sql:
|
||||||
|
return DatasourceKind.VIRTUAL.value
|
||||||
|
|
||||||
|
return DatasourceKind.PHYSICAL.value
|
||||||
|
|
||||||
@declared_attr
|
@declared_attr
|
||||||
def slices(self) -> RelationshipProperty:
|
def slices(self) -> RelationshipProperty:
|
||||||
return relationship(
|
return relationship(
|
||||||
|
|||||||
@@ -78,6 +78,11 @@ class DatasetRestApi(BaseSupersetModelRestApi):
|
|||||||
"changed_on",
|
"changed_on",
|
||||||
"default_endpoint",
|
"default_endpoint",
|
||||||
"explore_url",
|
"explore_url",
|
||||||
|
"kind",
|
||||||
|
"owners.id",
|
||||||
|
"owners.username",
|
||||||
|
"owners.first_name",
|
||||||
|
"owners.last_name",
|
||||||
"schema",
|
"schema",
|
||||||
"table_name",
|
"table_name",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import prison
|
|||||||
import yaml
|
import yaml
|
||||||
from sqlalchemy.sql import func
|
from sqlalchemy.sql import func
|
||||||
|
|
||||||
|
import tests.test_app
|
||||||
from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn
|
from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn
|
||||||
from superset.dao.exceptions import (
|
from superset.dao.exceptions import (
|
||||||
DAOCreateFailedError,
|
DAOCreateFailedError,
|
||||||
@@ -96,6 +97,8 @@ class DatasetApiTests(SupersetTestCase):
|
|||||||
"default_endpoint",
|
"default_endpoint",
|
||||||
"explore_url",
|
"explore_url",
|
||||||
"id",
|
"id",
|
||||||
|
"kind",
|
||||||
|
"owners",
|
||||||
"schema",
|
"schema",
|
||||||
"table_name",
|
"table_name",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user