feat: add certifications to tables (#11450)
This commit is contained in:
parent
f2b8d6aef8
commit
ca40877640
|
|
@ -516,6 +516,25 @@ class DatasourceEditor extends React.PureComponent {
|
|||
control={<TextControl controlId="fetch_values_predicate" />}
|
||||
/>
|
||||
)}
|
||||
{this.state.isSqla && (
|
||||
<Field
|
||||
fieldKey="extra"
|
||||
label={t('Extra')}
|
||||
description={t(
|
||||
'Extra data to specify table metadata. Currently supports ' +
|
||||
'certification data of the format: `{ "certification": { "certified_by": ' +
|
||||
'"Data Platform Team", "details": "This table is the source of truth." ' +
|
||||
'} }`.',
|
||||
)}
|
||||
control={
|
||||
<TextAreaControl
|
||||
controlId="extra"
|
||||
language="json"
|
||||
offerEditInModal={false}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<Field
|
||||
fieldKey="owners"
|
||||
label={t('Owners')}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { SupersetClient, t } from '@superset-ui/core';
|
||||
import { SupersetClient, t, styled } from '@superset-ui/core';
|
||||
import React, {
|
||||
FunctionComponent,
|
||||
useState,
|
||||
|
|
@ -44,10 +44,20 @@ import withToasts from 'src/messageToasts/enhancers/withToasts';
|
|||
import TooltipWrapper from 'src/components/TooltipWrapper';
|
||||
import Icon from 'src/components/Icon';
|
||||
import FacePile from 'src/components/FacePile';
|
||||
import CertifiedIconWithTooltip from 'src/components/CertifiedIconWithTooltip';
|
||||
import AddDatasetModal from './AddDatasetModal';
|
||||
|
||||
const PAGE_SIZE = 25;
|
||||
|
||||
const FlexRowContainer = styled.div`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
> svg {
|
||||
margin-right: ${({ theme }) => theme.gridUnit}px;
|
||||
}
|
||||
`;
|
||||
|
||||
type Dataset = {
|
||||
changed_by_name: string;
|
||||
changed_by_url: string;
|
||||
|
|
@ -178,9 +188,31 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
|
|||
{
|
||||
Cell: ({
|
||||
row: {
|
||||
original: { table_name: datasetTitle, explore_url: exploreURL },
|
||||
original: {
|
||||
extra,
|
||||
table_name: datasetTitle,
|
||||
explore_url: exploreURL,
|
||||
},
|
||||
},
|
||||
}: any) => <a href={exploreURL}>{datasetTitle}</a>,
|
||||
}: any) => {
|
||||
const titleLink = <a href={exploreURL}>{datasetTitle}</a>;
|
||||
try {
|
||||
const parsedExtra = JSON.parse(extra);
|
||||
return parsedExtra?.certification ? (
|
||||
<FlexRowContainer>
|
||||
<CertifiedIconWithTooltip
|
||||
certifiedBy={parsedExtra.certification.certified_by}
|
||||
details={parsedExtra.certification.details}
|
||||
/>
|
||||
{titleLink}
|
||||
</FlexRowContainer>
|
||||
) : (
|
||||
titleLink
|
||||
);
|
||||
} catch {
|
||||
return titleLink;
|
||||
}
|
||||
},
|
||||
Header: t('Name'),
|
||||
accessor: 'table_name',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -492,6 +492,7 @@ class SqlaTable( # pylint: disable=too-many-public-methods,too-many-instance-at
|
|||
sql = Column(Text)
|
||||
is_sqllab_view = Column(Boolean, default=False)
|
||||
template_params = Column(Text)
|
||||
extra = Column(Text)
|
||||
|
||||
baselink = "tablemodelview"
|
||||
|
||||
|
|
@ -509,6 +510,7 @@ class SqlaTable( # pylint: disable=too-many-public-methods,too-many-instance-at
|
|||
"template_params",
|
||||
"filter_select_enabled",
|
||||
"fetch_values_predicate",
|
||||
"extra",
|
||||
]
|
||||
update_from_object_fields = [f for f in export_fields if not f == "database_id"]
|
||||
export_parent = "database"
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class SqlMetricInlineView( # pylint: disable=too-many-ancestors
|
|||
"extra": utils.markdown(
|
||||
"Extra data to specify metric metadata. Currently supports "
|
||||
'certification data of the format: `{ "certification": "certified_by": '
|
||||
'"Taylor Swift", "details": "This metric is the source of truth." '
|
||||
'"Data Platform Team", "details": "This metric is the source of truth." '
|
||||
"} }`. This should be modified from the edit datasource model in "
|
||||
"Explore to ensure correct formatting.",
|
||||
True,
|
||||
|
|
@ -352,6 +352,7 @@ class TableModelView( # pylint: disable=too-many-ancestors
|
|||
"cache_timeout",
|
||||
"is_sqllab_view",
|
||||
"template_params",
|
||||
"extra",
|
||||
]
|
||||
base_filters = [["id", DatasourceFilter, lambda: []]]
|
||||
show_columns = edit_columns + ["perm", "slices"]
|
||||
|
|
@ -412,6 +413,13 @@ class TableModelView( # pylint: disable=too-many-ancestors
|
|||
"A timeout of 0 indicates that the cache never expires. "
|
||||
"Note this defaults to the database timeout if undefined."
|
||||
),
|
||||
"extra": utils.markdown(
|
||||
"Extra data to specify table metadata. Currently supports "
|
||||
'certification data of the format: `{ "certification": { "certified_by": '
|
||||
'"Data Platform Team", "details": "This table is the source of truth." '
|
||||
"} }`.",
|
||||
True,
|
||||
),
|
||||
}
|
||||
label_columns = {
|
||||
"slices": _("Associated Charts"),
|
||||
|
|
@ -432,6 +440,7 @@ class TableModelView( # pylint: disable=too-many-ancestors
|
|||
"description": _("Description"),
|
||||
"is_sqllab_view": _("SQL Lab View"),
|
||||
"template_params": _("Template parameters"),
|
||||
"extra": _("Extra"),
|
||||
"modified": _("Modified"),
|
||||
}
|
||||
edit_form_extra_fields = {
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
|
|||
"changed_on_delta_humanized",
|
||||
"default_endpoint",
|
||||
"explore_url",
|
||||
"extra",
|
||||
"kind",
|
||||
"owners.id",
|
||||
"owners.username",
|
||||
|
|
@ -135,6 +136,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
|
|||
"metrics",
|
||||
"datasource_type",
|
||||
"url",
|
||||
"extra",
|
||||
]
|
||||
add_model_schema = DatasetPostSchema()
|
||||
edit_model_schema = DatasetPutSchema()
|
||||
|
|
@ -155,6 +157,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
|
|||
"owners",
|
||||
"columns",
|
||||
"metrics",
|
||||
"extra",
|
||||
]
|
||||
openapi_spec_tag = "Datasets"
|
||||
related_field_filters = {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ class DatasetPutSchema(Schema):
|
|||
owners = fields.List(fields.Integer())
|
||||
columns = fields.List(fields.Nested(DatasetColumnsPutSchema))
|
||||
metrics = fields.List(fields.Nested(DatasetMetricsPutSchema))
|
||||
extra = fields.String(allow_none=True)
|
||||
|
||||
|
||||
class DatasetRelatedChart(Schema):
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ class TestExportDatabasesCommand(SupersetTestCase):
|
|||
"template_params": None,
|
||||
"filter_select_enabled": True,
|
||||
"fetch_values_predicate": None,
|
||||
"extra": None,
|
||||
"metrics": [
|
||||
{
|
||||
"metric_name": "ratio",
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ class TestDatasetApi(SupersetTestCase):
|
|||
"database",
|
||||
"default_endpoint",
|
||||
"explore_url",
|
||||
"extra",
|
||||
"id",
|
||||
"kind",
|
||||
"owners",
|
||||
|
|
@ -204,6 +205,7 @@ class TestDatasetApi(SupersetTestCase):
|
|||
"database": {"database_name": "examples", "id": 1},
|
||||
"default_endpoint": None,
|
||||
"description": "Energy consumption",
|
||||
"extra": None,
|
||||
"fetch_values_predicate": None,
|
||||
"filter_select_enabled": False,
|
||||
"is_sqllab_view": False,
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class TestExportDatasetsCommand(SupersetTestCase):
|
|||
"database_uuid": str(example_db.uuid),
|
||||
"default_endpoint": None,
|
||||
"description": "Energy consumption",
|
||||
"extra": None,
|
||||
"fetch_values_predicate": None,
|
||||
"filter_select_enabled": False,
|
||||
"main_dttm_col": None,
|
||||
|
|
@ -177,6 +178,7 @@ class TestExportDatasetsCommand(SupersetTestCase):
|
|||
"template_params",
|
||||
"filter_select_enabled",
|
||||
"fetch_values_predicate",
|
||||
"extra",
|
||||
"uuid",
|
||||
"metrics",
|
||||
"columns",
|
||||
|
|
|
|||
Loading…
Reference in New Issue