Kriskras99 commented on code in PR #579:
URL: https://github.com/apache/avro-rs/pull/579#discussion_r3578241892


##########
avro/src/types.rs:
##########
@@ -656,38 +687,70 @@ impl Value {
         }
     }
 
-    /// Attempt to perform schema resolution on the value, with the given
-    /// [Schema](../schema/enum.Schema.html).
+    /// Resolve this value into a new schema.
+    ///
+    /// Note: This will first build a reference map from the schema (see 
[`ResolvedSchema`]). If this
+    /// function is called more than once for the same schema, it is 
recommended to use
+    /// [`resolve_with_names`](Self::resolve_with_names) instead.
     ///
     /// See [Schema 
Resolution](https://avro.apache.org/docs/++version++/specification/#schema-resolution)
-    /// in the Avro specification for the full set of rules of schema
-    /// resolution.
+    /// in the Avro specification for the full set of rules of schema 
resolution.
     pub fn resolve(self, schema: &Schema) -> AvroResult<Self> {
         self.resolve_schemata(schema, Vec::with_capacity(0))
     }
 
-    /// Attempt to perform schema resolution on the value, with the given
-    /// [Schema](../schema/enum.Schema.html) and set of schemas to use for 
Refs resolution.
+    /// Resolve this value into a new schema using `schemata` to resolve any 
references.
+    ///
+    /// `schemata` must contain all referenced schemas in `schema`, including 
references to parts of
+    /// `schema` itself.
+    ///
+    /// Note: This will first build a reference map from the schema (see 
[`ResolvedSchema`]). If this
+    /// function is called more than once for the same schema, it is 
recommended to use
+    /// [`resolve_with_names`](Self::resolve_with_names) instead.
     ///
     /// See [Schema 
Resolution](https://avro.apache.org/docs/++version++/specification/#schema-resolution)
-    /// in the Avro specification for the full set of rules of schema
-    /// resolution.
+    /// in the Avro specification for the full set of rules of schema 
resolution.
     pub fn resolve_schemata(self, schema: &Schema, schemata: Vec<&Schema>) -> 
AvroResult<Self> {
-        let enclosing_namespace = schema.namespace();

Review Comment:
   The only schemas for which `schema.namespace()` will return a namespace are:
   - `Schema::Ref`
   - `Schema::Record`
   - `Schema::Enum`
   - `Schema::Fixed`
   - `Schema::Decimal(Fixed)`
   - `Schema::Uuid(Fixed)`
   - `Schema::Duration`
   
   `resolve_internal` will only use the `enclosing_namespace` parameter in the 
following situations:
   - `schema == Schema::Ref` to get the fqn of the reference. But if the 
reference has a namespace that will be used for the fqn
   - `schema == Schema::Union`, but directly from `resolve_schemata` the 
enclosing namespace will not exist
   - `schema == Schema::Array`, same as union
   - `schema == Schema::Map`, same as union
   - `schema == Schema::Record`, it should use the namespace from the record 
first but I see now that it doesn't. 
   
   I've updated the `Schema::Record` branch to use the namespace from the 
record first then the enclosing namespace if it does not have one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to