mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-18 20:30:48 +00:00
Merge branch 'main' into chore-lineage-styles
This commit is contained in:
commit
fd915acdb3
@ -425,7 +425,16 @@ public class SchemaFieldExtractor {
|
||||
}
|
||||
|
||||
private static String determineReferenceType(String refUri) {
|
||||
// Pattern to extract the definition name if present
|
||||
// Handle internal schema references first (e.g., #/definitions/column,
|
||||
// #/definitions/tableConstraint, etc.)
|
||||
if (refUri.startsWith("#/definitions/")) {
|
||||
String definitionName = refUri.substring("#/definitions/".length());
|
||||
LOG.debug("Found internal schema reference: {}", definitionName);
|
||||
// Return the definition name as the type - this preserves the actual type name
|
||||
return definitionName;
|
||||
}
|
||||
|
||||
// Pattern to extract the definition name if present from external files
|
||||
Pattern definitionPattern = Pattern.compile("^(?:.*/)?basic\\.json#/definitions/([\\w-]+)$");
|
||||
Matcher matcher = definitionPattern.matcher(refUri);
|
||||
if (matcher.find()) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
package org.openmetadata.service.resources.metadata;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||
import static org.openmetadata.service.util.EntityUtil.fieldAdded;
|
||||
@ -505,6 +506,54 @@ public class TypeResourceTest extends EntityResourceTest<Type, CreateType> {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_getEntityTypeFields_internalSchemaReferences() throws HttpResponseException {
|
||||
// Test that internal schema references like #/definitions/column are handled correctly
|
||||
WebTarget target = getCollection().path("/fields/table");
|
||||
List<Map<String, Object>> fields = TestUtils.get(target, List.class, ADMIN_AUTH_HEADERS);
|
||||
|
||||
// Find the columns field
|
||||
Map<String, Object> columnsField =
|
||||
fields.stream()
|
||||
.filter(field -> "columns".equals(field.get("name")))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// Verify columns field exists and has correct type
|
||||
assertNotNull(columnsField, "columns field should be present");
|
||||
assertEquals(
|
||||
"array<column>",
|
||||
columnsField.get("type"),
|
||||
"columns field should be of type array<column>, not array<string>");
|
||||
|
||||
// Verify that nested column properties are exposed
|
||||
boolean hasColumnName =
|
||||
fields.stream().anyMatch(field -> "columns.name".equals(field.get("name")));
|
||||
boolean hasColumnDescription =
|
||||
fields.stream().anyMatch(field -> "columns.description".equals(field.get("name")));
|
||||
boolean hasColumnDataType =
|
||||
fields.stream().anyMatch(field -> "columns.dataType".equals(field.get("name")));
|
||||
|
||||
assertTrue(hasColumnName, "columns.name field should be exposed");
|
||||
assertTrue(hasColumnDescription, "columns.description field should be exposed");
|
||||
assertTrue(hasColumnDataType, "columns.dataType field should be exposed");
|
||||
|
||||
// Test other internal schema references
|
||||
Map<String, Object> dataModelField =
|
||||
fields.stream()
|
||||
.filter(field -> "dataModel".equals(field.get("name")))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
assertNotNull(dataModelField, "dataModel field should be present");
|
||||
assertEquals("dataModel", dataModelField.get("type"), "dataModel should be of type object");
|
||||
|
||||
// Verify nested dataModel properties are exposed
|
||||
boolean hasDataModelColumns =
|
||||
fields.stream().anyMatch(field -> "dataModel.columns".equals(field.get("name")));
|
||||
assertTrue(hasDataModelColumns, "dataModel.columns field should be exposed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) {
|
||||
if (expected == actual) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user