From f489b3086021f6e7b9f3949977df56dd5a0f4e6b Mon Sep 17 00:00:00 2001 From: Alexandra Konrad Date: Thu, 27 Jun 2024 15:17:29 +0200 Subject: [PATCH] added extends together with embed test --- crates/weaver_resolved_schema/src/lineage.rs | 7 +- .../README.md | 1 + .../expected-attribute-catalog.json | 83 ++++++++ .../expected-registry.json | 181 ++++++++++++++++++ .../registry/client.yaml | 15 ++ .../registry/geo.yaml | 24 +++ .../registry/usage.yaml | 12 ++ .../registry/usage2.yaml | 9 + 8 files changed, 326 insertions(+), 6 deletions(-) create mode 100644 crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/README.md create mode 100644 crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-attribute-catalog.json create mode 100644 crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-registry.json create mode 100644 crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/client.yaml create mode 100644 crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/geo.yaml create mode 100644 crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage.yaml create mode 100644 crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage2.yaml diff --git a/crates/weaver_resolved_schema/src/lineage.rs b/crates/weaver_resolved_schema/src/lineage.rs index d906b57b..32b127f3 100644 --- a/crates/weaver_resolved_schema/src/lineage.rs +++ b/crates/weaver_resolved_schema/src/lineage.rs @@ -399,12 +399,7 @@ impl AttributeLineage { } } - /// Determines the value of the tags field by evaluating the presence of - /// a local value. If a local value is provided, it is used, and the tags - /// field's lineage is marked as local. Otherwise, the specified parent - /// value is used, and the tags field's lineage is marked as inherited - /// from the parent. - /// This method updates the lineage information for the tags field to + /// This method updates the lineage information for the prefix field to /// reflect the source of its value. pub fn prefix(&mut self, local_value: &bool, parent_value: &bool) -> bool { if *local_value { diff --git a/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/README.md b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/README.md new file mode 100644 index 00000000..8f28dd72 --- /dev/null +++ b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/README.md @@ -0,0 +1 @@ +Test adding a prefix to the references in attributes together with extends keyword. \ No newline at end of file diff --git a/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-attribute-catalog.json b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-attribute-catalog.json new file mode 100644 index 00000000..12e05769 --- /dev/null +++ b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-attribute-catalog.json @@ -0,0 +1,83 @@ +[ + { + "name": "client.id", + "type": "string", + "brief": "some client id\n", + "examples": [ + "a.einstein" + ], + "requirement_level": "recommended", + "stability": "experimental" + }, + { + "name": "geo.lat", + "type": "string", + "brief": "latitude of the geo coordinates.\n", + "examples": [ + "123.456" + ], + "requirement_level": "recommended", + "stability": "experimental" + }, + { + "name": "geo.lon", + "type": "string", + "brief": "longitude of the geo coordinates.\n", + "examples": [ + "234.456" + ], + "requirement_level": "recommended", + "stability": "experimental" + }, + { + "name": "geo.country", + "type": "string", + "brief": "country of the geo coordinates.\n", + "examples": [ + "US" + ], + "requirement_level": "recommended", + "stability": "experimental" + }, + { + "name": "geo.lat", + "type": "string", + "brief": "this is ref attribute", + "examples": [ + "123.456" + ], + "requirement_level": "recommended", + "stability": "experimental" + }, + { + "name": "geo.country", + "type": "string", + "brief": "this is ref country attribute", + "examples": [ + "US" + ], + "requirement_level": "recommended", + "stability": "experimental" + }, + { + "name": "client.geo.lat", + "type": "string", + "brief": "My own latitude", + "examples": [ + "123.456" + ], + "requirement_level": "recommended", + "stability": "experimental", + "prefix": true + }, + { + "name": "client.geo.lat", + "type": "string", + "brief": "this is embedded attribute", + "examples": [ + "123.456" + ], + "requirement_level": "recommended", + "stability": "experimental" + } +] \ No newline at end of file diff --git a/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-registry.json b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-registry.json new file mode 100644 index 00000000..61032781 --- /dev/null +++ b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/expected-registry.json @@ -0,0 +1,181 @@ +{ + "registry_url": "https://127.0.0.1", + "groups": [ + { + "id": "registry.client", + "type": "attribute_group", + "brief": "Describes information about the client.", + "prefix": "client", + "attributes": [ + 0, + 6 + ], + "lineage": { + "source_file": "data/registry-test-11-prefix-refs-extends/registry/client.yaml", + "attributes": { + "client.geo.lat": { + "source_group": "registry.geo", + "inherited_fields": [ + "examples", + "note", + "requirement_level", + "stability" + ], + "locally_overridden_fields": [ + "brief" + ] + } + } + } + }, + { + "id": "registry.geo", + "type": "attribute_group", + "brief": "Attributes describing geo.", + "prefix": "geo", + "attributes": [ + 1, + 2, + 3 + ], + "lineage": { + "source_file": "data/registry-test-11-prefix-refs-extends/registry/geo.yaml" + } + }, + { + "id": "usage", + "type": "attribute_group", + "brief": "Attributes for test.", + "prefix": "usage", + "attributes": [ + 0, + 2, + 4, + 7 + ], + "lineage": { + "source_file": "data/registry-test-11-prefix-refs-extends/registry/usage.yaml", + "attributes": { + "client.geo.lat": { + "source_group": "registry.client", + "inherited_fields": [ + "examples", + "note", + "requirement_level", + "stability" + ], + "locally_overridden_fields": [ + "brief" + ] + }, + "client.id": { + "source_group": "registry.client", + "inherited_fields": [ + "brief", + "examples", + "note", + "requirement_level", + "stability" + ] + }, + "geo.lat": { + "source_group": "registry.geo", + "inherited_fields": [ + "examples", + "note", + "requirement_level", + "stability" + ], + "locally_overridden_fields": [ + "brief" + ] + }, + "geo.lon": { + "source_group": "registry.geo", + "inherited_fields": [ + "brief", + "examples", + "note", + "requirement_level", + "stability" + ] + } + } + } + }, + { + "id": "usage2", + "type": "attribute_group", + "brief": "Attributes for test.", + "prefix": "usage2", + "attributes": [ + 0, + 2, + 4, + 5, + 7 + ], + "lineage": { + "source_file": "data/registry-test-11-prefix-refs-extends/registry/usage2.yaml", + "attributes": { + "client.geo.lat": { + "source_group": "registry.client", + "inherited_fields": [ + "examples", + "note", + "requirement_level", + "stability" + ], + "locally_overridden_fields": [ + "brief" + ] + }, + "client.id": { + "source_group": "registry.client", + "inherited_fields": [ + "brief", + "examples", + "note", + "requirement_level", + "stability" + ] + }, + "geo.country": { + "source_group": "registry.geo", + "inherited_fields": [ + "examples", + "note", + "requirement_level", + "stability" + ], + "locally_overridden_fields": [ + "brief" + ] + }, + "geo.lat": { + "source_group": "registry.geo", + "inherited_fields": [ + "examples", + "note", + "requirement_level", + "stability" + ], + "locally_overridden_fields": [ + "brief" + ] + }, + "geo.lon": { + "source_group": "registry.geo", + "inherited_fields": [ + "brief", + "examples", + "note", + "requirement_level", + "stability" + ] + } + } + } + } + ] +} \ No newline at end of file diff --git a/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/client.yaml b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/client.yaml new file mode 100644 index 00000000..97d88f68 --- /dev/null +++ b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/client.yaml @@ -0,0 +1,15 @@ +groups: + - id: registry.client + prefix: client + type: attribute_group + brief: "Describes information about the client." + attributes: + - id: id + type: string + stability: experimental + brief: > + some client id + examples: ['a.einstein'] + - ref: geo.lat + prefix: true + brief: My own latitude \ No newline at end of file diff --git a/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/geo.yaml b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/geo.yaml new file mode 100644 index 00000000..51693c48 --- /dev/null +++ b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/geo.yaml @@ -0,0 +1,24 @@ +groups: + - id: registry.geo + brief: Attributes describing geo. + type: attribute_group + prefix: geo + attributes: + - id: lat + type: string + stability: experimental + brief: > + latitude of the geo coordinates. + examples: ["123.456"] + - id: lon + type: string + stability: experimental + brief: > + longitude of the geo coordinates. + examples: [ "234.456" ] + - id: country + type: string + stability: experimental + brief: > + country of the geo coordinates. + examples: [ "US" ] diff --git a/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage.yaml b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage.yaml new file mode 100644 index 00000000..4c1beda0 --- /dev/null +++ b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage.yaml @@ -0,0 +1,12 @@ +groups: + - id: usage + brief: Attributes for test. + type: attribute_group + prefix: usage + attributes: + - ref: geo.lat + brief: this is ref attribute + - ref: client.id + - ref: geo.lon + - ref: client.geo.lat + brief: this is embedded attribute diff --git a/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage2.yaml b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage2.yaml new file mode 100644 index 00000000..a6a559ca --- /dev/null +++ b/crates/weaver_resolver/data/registry-test-11-prefix-refs-extends/registry/usage2.yaml @@ -0,0 +1,9 @@ +groups: + - id: usage2 + brief: Attributes for test. + type: attribute_group + prefix: usage2 + extends: usage + attributes: + - ref: geo.country + brief: this is ref country attribute