fix: supportedDataType PSQL query (#17069)

This commit is contained in:
Teddy 2024-07-18 16:47:05 +02:00 committed by GitHub
parent aa3d54aede
commit e4b31f9d65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 6 deletions

View File

@ -3688,8 +3688,9 @@ public interface CollectionDAO {
if (supportedDataType != null) {
filter.queryParams.put("supportedDataTypeLike", String.format("%%%s%%", supportedDataType));
mysqlCondition.append("AND supported_data_types LIKE :supportedDataTypeLike");
psqlCondition.append("AND supported_data_types @> :supportedDataTypeLike ");
mysqlCondition.append(
"AND json_extract(json, '$.supportedDataTypes') LIKE :supportedDataTypeLike ");
psqlCondition.append("AND json->>'supportedDataTypes' LIKE :supportedDataTypeLike ");
}
return listBefore(
@ -3731,8 +3732,9 @@ public interface CollectionDAO {
if (supportedDataType != null) {
filter.queryParams.put("supportedDataTypeLike", String.format("%%%s%%", supportedDataType));
mysqlCondition.append("AND supported_data_types LIKE :supportedDataTypeLike");
psqlCondition.append("AND supported_data_types @> :supportedDataTypeLike ");
mysqlCondition.append(
"AND json_extract(json, '$.supportedDataTypes') LIKE :supportedDataTypeLike ");
psqlCondition.append("AND json->>'supportedDataTypes' LIKE :supportedDataTypeLike ");
}
return listAfter(
@ -3774,8 +3776,9 @@ public interface CollectionDAO {
if (supportedDataType != null) {
filter.queryParams.put("supportedDataTypeLike", String.format("%%%s%%", supportedDataType));
mysqlCondition.append("AND supported_data_types LIKE :supportedDataTypeLike");
psqlCondition.append("AND supported_data_types @> :supportedDataTypeLike ");
mysqlCondition.append(
"AND json_extract(json, '$.supportedDataTypes') LIKE :supportedDataTypeLike ");
psqlCondition.append("AND json->>'supportedDataTypes' LIKE :supportedDataTypeLike ");
}
return listCount(
getTableName(),

View File

@ -21,6 +21,7 @@ import org.openmetadata.schema.api.tests.CreateTestDefinition;
import org.openmetadata.schema.tests.TestCaseParameter;
import org.openmetadata.schema.tests.TestDefinition;
import org.openmetadata.schema.tests.TestPlatform;
import org.openmetadata.schema.type.ColumnDataType;
import org.openmetadata.schema.type.TestDefinitionEntityType;
import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.EntityResourceTest;
@ -51,6 +52,16 @@ public class TestDefinitionResourceTest
"columnValuesMissingCount", "owner", ADMIN_AUTH_HEADERS);
}
@Test
void list_testDefinitionsForBoolType(TestInfo test) throws HttpResponseException {
Map<String, String> params = Map.of("supportedDataType", "BOOLEAN");
ResultList<TestDefinition> testDefinitions = listEntities(params, ADMIN_AUTH_HEADERS);
boolean b =
testDefinitions.getData().stream()
.allMatch(t -> t.getSupportedDataTypes().contains(ColumnDataType.BOOLEAN));
Assertions.assertTrue(b);
}
@Test
void post_testDefinitionWithoutRequiredFields_4xx(TestInfo test) {
// Test Platform is required field