From 5cef4c6f7681400a03a3648766f584e3d3594a2d Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 27 Jun 2023 08:27:05 +0200 Subject: [PATCH] Address backend DQ feedback (#12150) * fix: add jp and zh index * fix: updated testCase tooltips * fix: changed list testSuite permission to VEW_TEST + set owner of table for executable testSuite --- .../resources/dqtests/TestSuiteResource.java | 23 +- .../jp/test_case_index_mapping.json | 325 ++++++++++++++++++ .../zh/test_case_index_mapping.json | 315 +++++++++++++++++ .../tests/columnValueMeanToBeBetween.json | 2 +- .../tests/columnValueMedianToBeBetween.json | 2 +- .../tests/columnValueStdDevToBeBetween.json | 2 +- .../tests/columnValuesLengthsToBeBetween.json | 4 +- .../data/tests/columnValuesToBeBetween.json | 4 +- .../data/tests/tableColumnToMatchSet.json | 2 +- .../data/tests/tableRowCountToBeBetween.json | 4 +- 10 files changed, 672 insertions(+), 11 deletions(-) create mode 100644 openmetadata-service/src/main/resources/elasticsearch/jp/test_case_index_mapping.json create mode 100644 openmetadata-service/src/main/resources/elasticsearch/zh/test_case_index_mapping.json diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java index 899f16f8e3f8..5dc3ae17afb7 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java @@ -52,6 +52,8 @@ import org.openmetadata.service.resources.EntityResource; import org.openmetadata.service.security.Authorizer; import org.openmetadata.service.security.policyevaluator.OperationContext; +import org.openmetadata.service.security.policyevaluator.ResourceContext; +import org.openmetadata.service.util.EntityUtil; import org.openmetadata.service.util.FullyQualifiedName; import org.openmetadata.service.util.RestUtil; import org.openmetadata.service.util.ResultList; @@ -143,7 +145,14 @@ public ResultList list( throws IOException { ListFilter filter = new ListFilter(include); filter.addQueryParam("testSuiteType", testSuiteType); - return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after); + EntityUtil.Fields fields = getFields(fieldsParam); + + ResourceContext resourceContext; + resourceContext = getResourceContext(entityType, repository).build(); + OperationContext operationContext = new OperationContext(Entity.TABLE, MetadataOperation.VIEW_TESTS); + + return super.listInternal( + uriInfo, securityContext, fields, filter, limitParam, before, after, operationContext, resourceContext); } @GET @@ -298,6 +307,7 @@ public Response createExecutable( Entity.getEntityByName(Entity.TABLE, create.getExecutableEntityReference(), null, null); // check if entity exists TestSuite testSuite = getTestSuite(create, securityContext.getUserPrincipal().getName()); testSuite.setExecutable(true); + testSuite = setExecutableTestSuiteOwner(testSuite); testSuite = setExecutableTestSuiteName(testSuite); return create(uriInfo, securityContext, testSuite); } @@ -550,6 +560,17 @@ private TestSuite setExecutableTestSuiteName(TestSuite testSuite) { return testSuite.withDisplayName(name).withName(hashedName); } + private TestSuite setExecutableTestSuiteOwner(TestSuite testSuite) throws IOException { + Table tableEntity = + Entity.getEntity( + testSuite.getExecutableEntityReference().getType(), + testSuite.getExecutableEntityReference().getId(), + "owner", + ALL); + EntityReference ownerReference = tableEntity.getOwner(); + return testSuite.withOwner(ownerReference); + } + @Override public TestSuite getByNameInternal( UriInfo uriInfo, SecurityContext securityContext, String name, String fieldsParam, Include include) diff --git a/openmetadata-service/src/main/resources/elasticsearch/jp/test_case_index_mapping.json b/openmetadata-service/src/main/resources/elasticsearch/jp/test_case_index_mapping.json new file mode 100644 index 000000000000..3f72d0d4ba1d --- /dev/null +++ b/openmetadata-service/src/main/resources/elasticsearch/jp/test_case_index_mapping.json @@ -0,0 +1,325 @@ +{ + "settings": { + "analysis": { + "normalizer": { + "lowercase_normalizer": { + "type": "custom", + "char_filter": [], + "filter": [ + "lowercase" + ] + } + }, + "analyzer": { + "om_analyzer": { + "tokenizer": "letter", + "filter": [ + "lowercase", + "om_stemmer" + ] + }, + "om_analyzer_jp" : { + "tokenizer" : "kuromoji_tokenizer", + "type" : "custom", + "filter" : [ + "kuromoji_baseform", + "kuromoji_part_of_speech", + "kuromoji_number", + "kuromoji_stemmer" + ] + }, + "om_ngram": { + "tokenizer": "ngram", + "min_gram": 1, + "max_gram": 2, + "filter": [ + "lowercase" + ] + } + }, + "filter": { + "om_stemmer": { + "type": "stemmer", + "name": "english" + } + } + } + }, + "mappings": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "text", + "analyzer": "om_analyzer_jp", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "fullyQualifiedName": { + "type": "keyword", + "normalizer": "lowercase_normalizer" + }, + "displayName": { + "type": "text", + "analyzer": "om_analyzer_jp", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "description": { + "type": "text", + "analyzer": "om_analyzer_jp", + "fields": { + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "entityLink": { + "type": "text" + }, + "entityFQN": { + "type": "keyword", + "normalizer": "lowercase_normalizer" + }, + "parameterValues": { + "properties": { + "name": { + "type": "text", + "analyzer": "om_analyzer_jp", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "value": { + "type": "text" + } + } + }, + "testDefinition": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "text", + "analyzer": "om_analyzer_jp", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "fullyQualifiedName": { + "type": "keyword", + "normalizer": "lowercase_normalizer" + }, + "displayName": { + "type": "text", + "analyzer": "om_analyzer_jp", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "description": { + "type": "text", + "analyzer": "om_analyzer_jp", + "fields": { + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "entityType": { + "type": "keyword" + }, + "testPlatforms": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "owner": { + "properties": { + "id": { + "type": "text" + }, + "type": { + "type": "keyword" + }, + "name": { + "type": "keyword", + "normalizer": "lowercase_normalizer", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "displayName": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "fullyQualifiedName": { + "type": "text" + }, + "description": { + "type": "text" + }, + "deleted": { + "type": "text" + }, + "href": { + "type": "text" + } + } + }, + "testSuite": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "keyword", + "normalizer": "lowercase_normalizer", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "displayName": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "fullyQualifiedName": { + "type": "text" + }, + "description": { + "type": "text" + }, + "deleted": { + "type": "text" + }, + "href": { + "type": "text" + }, + "executable": { + "type": "text" + } + } + }, + "testSuites": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "keyword", + "normalizer": "lowercase_normalizer", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "displayName": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "fullyQualifiedName": { + "type": "text" + }, + "description": { + "type": "text" + }, + "deleted": { + "type": "text" + }, + "href": { + "type": "text" + }, + "executable": { + "type": "text" + } + } + }, + "version": { + "type": "float" + }, + "updatedAt": { + "type": "date", + "format": "epoch_second" + }, + "updatedBy": { + "type": "text" + }, + "href": { + "type": "text" + }, + "deleted": { + "type": "text" + } + } + } +} \ No newline at end of file diff --git a/openmetadata-service/src/main/resources/elasticsearch/zh/test_case_index_mapping.json b/openmetadata-service/src/main/resources/elasticsearch/zh/test_case_index_mapping.json new file mode 100644 index 000000000000..0289bbf0964a --- /dev/null +++ b/openmetadata-service/src/main/resources/elasticsearch/zh/test_case_index_mapping.json @@ -0,0 +1,315 @@ +{ + "settings": { + "analysis": { + "normalizer": { + "lowercase_normalizer": { + "type": "custom", + "char_filter": [], + "filter": [ + "lowercase" + ] + } + }, + "analyzer": { + "om_analyzer": { + "tokenizer": "letter", + "filter": [ + "lowercase", + "om_stemmer" + ] + }, + "om_ngram": { + "tokenizer": "ngram", + "min_gram": 1, + "max_gram": 2, + "filter": [ + "lowercase" + ] + } + }, + "filter": { + "om_stemmer": { + "type": "stemmer", + "name": "english" + } + } + } + }, + "mappings": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "text", + "analyzer": "ik_max_word", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "fullyQualifiedName": { + "type": "keyword", + "normalizer": "lowercase_normalizer" + }, + "displayName": { + "type": "text", + "analyzer": "ik_max_word", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "description": { + "type": "text", + "analyzer": "ik_max_word", + "fields": { + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "entityLink": { + "type": "text" + }, + "entityFQN": { + "type": "keyword", + "normalizer": "lowercase_normalizer" + }, + "parameterValues": { + "properties": { + "name": { + "type": "text", + "analyzer": "ik_max_word", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "value": { + "type": "text" + } + } + }, + "testDefinition": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "text", + "analyzer": "ik_max_word", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "fullyQualifiedName": { + "type": "keyword", + "normalizer": "lowercase_normalizer" + }, + "displayName": { + "type": "text", + "analyzer": "ik_max_word", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + }, + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "description": { + "type": "text", + "analyzer": "ik_max_word", + "fields": { + "ngram": { + "type": "text", + "analyzer": "om_ngram" + } + } + }, + "entityType": { + "type": "keyword" + }, + "testPlatforms": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + } + } + }, + "owner": { + "properties": { + "id": { + "type": "text" + }, + "type": { + "type": "keyword" + }, + "name": { + "type": "keyword", + "normalizer": "lowercase_normalizer", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "displayName": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "fullyQualifiedName": { + "type": "text" + }, + "description": { + "type": "text" + }, + "deleted": { + "type": "text" + }, + "href": { + "type": "text" + } + } + }, + "testSuite": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "keyword", + "normalizer": "lowercase_normalizer", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "displayName": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "fullyQualifiedName": { + "type": "text" + }, + "description": { + "type": "text" + }, + "deleted": { + "type": "text" + }, + "href": { + "type": "text" + }, + "executable": { + "type": "text" + } + } + }, + "testSuites": { + "properties": { + "id": { + "type": "text" + }, + "name": { + "type": "keyword", + "normalizer": "lowercase_normalizer", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "displayName": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256 + } + } + }, + "fullyQualifiedName": { + "type": "text" + }, + "description": { + "type": "text" + }, + "deleted": { + "type": "text" + }, + "href": { + "type": "text" + }, + "executable": { + "type": "text" + } + } + }, + "version": { + "type": "float" + }, + "updatedAt": { + "type": "date", + "format": "epoch_second" + }, + "updatedBy": { + "type": "text" + }, + "href": { + "type": "text" + }, + "deleted": { + "type": "text" + } + } + } +} \ No newline at end of file diff --git a/openmetadata-service/src/main/resources/json/data/tests/columnValueMeanToBeBetween.json b/openmetadata-service/src/main/resources/json/data/tests/columnValueMeanToBeBetween.json index 32867905b9c8..bfc7b1858107 100644 --- a/openmetadata-service/src/main/resources/json/data/tests/columnValueMeanToBeBetween.json +++ b/openmetadata-service/src/main/resources/json/data/tests/columnValueMeanToBeBetween.json @@ -16,7 +16,7 @@ { "name": "maxValueForMeanInCol", "displayName": "Max", - "description": "Expected mean value for the column to be greater or equal than", + "description": "Expected mean value for the column to be lower or equal than", "dataType": "INT" } ] diff --git a/openmetadata-service/src/main/resources/json/data/tests/columnValueMedianToBeBetween.json b/openmetadata-service/src/main/resources/json/data/tests/columnValueMedianToBeBetween.json index 178dbbe66f74..fed513992d27 100644 --- a/openmetadata-service/src/main/resources/json/data/tests/columnValueMedianToBeBetween.json +++ b/openmetadata-service/src/main/resources/json/data/tests/columnValueMedianToBeBetween.json @@ -16,7 +16,7 @@ { "name": "maxValueForMedianInCol", "displayName": "Max", - "description": "Expected median value for the column to be greater or equal than", + "description": "Expected median value for the column to be lower or equal than", "dataType": "INT" } ] diff --git a/openmetadata-service/src/main/resources/json/data/tests/columnValueStdDevToBeBetween.json b/openmetadata-service/src/main/resources/json/data/tests/columnValueStdDevToBeBetween.json index 1dc34d69b813..dc9e801e31c3 100644 --- a/openmetadata-service/src/main/resources/json/data/tests/columnValueStdDevToBeBetween.json +++ b/openmetadata-service/src/main/resources/json/data/tests/columnValueStdDevToBeBetween.json @@ -16,7 +16,7 @@ { "name": "maxValueForStdDevInCol", "displayName": "Max", - "description": "Expected std. dev value for the column to be greater or equal than", + "description": "Expected std. dev value for the column to be lower or equal than", "dataType": "INT" } ] diff --git a/openmetadata-service/src/main/resources/json/data/tests/columnValuesLengthsToBeBetween.json b/openmetadata-service/src/main/resources/json/data/tests/columnValuesLengthsToBeBetween.json index da4eaf60ba45..3389d009e9f1 100644 --- a/openmetadata-service/src/main/resources/json/data/tests/columnValuesLengthsToBeBetween.json +++ b/openmetadata-service/src/main/resources/json/data/tests/columnValuesLengthsToBeBetween.json @@ -10,13 +10,13 @@ { "name": "minLength", "displayName": "Min", - "description": "The {minLength} for the column length. If minLength is not included, maxLength is treated as upperBound and there will be no minimum number of rows", + "description": "The {minLength} for the column value. If minLength is not included, maxLength is treated as upperBound and there will be no minimum value length", "dataType": "INT" }, { "name": "maxLength", "displayName": "Max", - "description": "The {maxLength} for the column length. if maxLength is not included, minLength is treated as lowerBound and there will eb no maximum number of rows", + "description": "The {maxLength} for the column value. if maxLength is not included, minLength is treated as lowerBound and there will be no maximum value length", "dataType": "INT" } ] diff --git a/openmetadata-service/src/main/resources/json/data/tests/columnValuesToBeBetween.json b/openmetadata-service/src/main/resources/json/data/tests/columnValuesToBeBetween.json index b5bf252df10a..0cd0c5cb8f2b 100644 --- a/openmetadata-service/src/main/resources/json/data/tests/columnValuesToBeBetween.json +++ b/openmetadata-service/src/main/resources/json/data/tests/columnValuesToBeBetween.json @@ -10,13 +10,13 @@ { "name": "minValue", "displayName": "Min", - "description": "The {minValue} value for the column entry. If minValue is not included, maxValue is treated as upperBound and there will be no minimum number of rows", + "description": "The {minValue} value for the column entry. If minValue is not included, maxValue is treated as upperBound and there will be no minimum", "dataType": "INT" }, { "name": "maxValue", "displayName": "Max", - "description": "The {maxValue} value for the column entry. if maxValue is not included, minValue is treated as lowerBound and there will eb no maximum number of rows", + "description": "The {maxValue} value for the column entry. if maxValue is not included, minValue is treated as lowerBound and there will be no maximum", "dataType": "INT" } ] diff --git a/openmetadata-service/src/main/resources/json/data/tests/tableColumnToMatchSet.json b/openmetadata-service/src/main/resources/json/data/tests/tableColumnToMatchSet.json index bdb0eaaaf800..87db21db025e 100644 --- a/openmetadata-service/src/main/resources/json/data/tests/tableColumnToMatchSet.json +++ b/openmetadata-service/src/main/resources/json/data/tests/tableColumnToMatchSet.json @@ -9,7 +9,7 @@ { "name": "columnNames", "displayName": "Column Names", - "description": "Expected columns names of the table to match the ones in {Column Names} -- should be a coma seperated string", + "description": "Expected columns names of the table to match the ones in {Column Names} -- should be a coma separated string", "dataType": "STRING", "required": "true" }, diff --git a/openmetadata-service/src/main/resources/json/data/tests/tableRowCountToBeBetween.json b/openmetadata-service/src/main/resources/json/data/tests/tableRowCountToBeBetween.json index 0eef5b5decb7..5b1aaee9bb4c 100644 --- a/openmetadata-service/src/main/resources/json/data/tests/tableRowCountToBeBetween.json +++ b/openmetadata-service/src/main/resources/json/data/tests/tableRowCountToBeBetween.json @@ -9,13 +9,13 @@ { "name": "minValue", "displayName": "Min", - "description": "Expected number of columns should be greater than or equal to {minValue}. If minValue is not included, maxValue is treated as upperBound and there will be no minimum number of column", + "description": "Expected number of columns should be greater than or equal to {minValue}. If minValue is not included, maxValue is treated as upperBound and there will be no minimum", "dataType": "INT" }, { "name": "maxValue", "displayName": "Max", - "description": "Expected number of columns should be less than or equal to {maxValue}. If maxValue is not included, minValue is treated as lowerBound and there will be no maximum number of column", + "description": "Expected number of columns should be less than or equal to {maxValue}. If maxValue is not included, minValue is treated as lowerBound and there will be no maximum", "dataType": "INT" } ]