You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "martin-g (via GitHub)" <gi...@apache.org> on 2026/01/19 10:33:32 UTC

[PR] fix: Calculate the RecordSchema's `lookup` table on build [avro-rs]

martin-g opened a new pull request, #411:
URL: https://github.com/apache/avro-rs/pull/411

   Fixes #403


-- 
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: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: Calculate the RecordSchema's `lookup` table on build [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #411:
URL: https://github.com/apache/avro-rs/pull/411#discussion_r2704371968


##########
avro/src/schema/record/schema.rs:
##########
@@ -34,12 +34,22 @@ pub struct RecordSchema {
     pub fields: Vec<RecordField>,

Review Comment:
   ```suggestion
       #[builder(default)]
       pub fields: Vec<RecordField>,
   ```



##########
avro/src/schema/record/schema.rs:
##########
@@ -34,12 +34,22 @@ pub struct RecordSchema {
     pub fields: Vec<RecordField>,
     /// The `lookup` table maps field names to their position in the `Vec`
     /// of `fields`.
+    #[builder(skip = calculate_lookup_table(&fields))]
     pub lookup: BTreeMap<String, usize>,
     /// The custom attributes of the schema
-    #[builder(default = BTreeMap::new())]
+    #[builder(default = Default::default())]

Review Comment:
   ```suggestion
       #[builder(default)]
   ```



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: Calculate the RecordSchema's `lookup` table on build [avro-rs]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g merged PR #411:
URL: https://github.com/apache/avro-rs/pull/411


-- 
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: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: Calculate the RecordSchema's `lookup` table on build [avro-rs]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #411:
URL: https://github.com/apache/avro-rs/pull/411#discussion_r2704180911


##########
avro/src/schema/record/schema.rs:
##########
@@ -49,3 +59,105 @@ pub(crate) enum RecordSchemaParseLocation {
     /// When the parse is happening inside a record field
     FromField,
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::Schema;
+    use apache_avro_test_helper::TestResult;
+    use pretty_assertions::assert_eq;
+
+    #[test]
+    fn avro_rs_403_record_schema_builder_no_fields() -> TestResult {
+        let name = Name::new("TestRecord")?;
+
+        let record_schema = RecordSchema::builder()
+            .name(name.clone())
+            .fields(vec![])

Review Comment:
   I does not make much sense to have a RecordSchema without fields but it was possible until now, so I left it as is.



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: Calculate the RecordSchema's `lookup` table on build [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #411:
URL: https://github.com/apache/avro-rs/pull/411#discussion_r2704367800


##########
avro/src/schema/record/schema.rs:
##########
@@ -49,3 +59,105 @@ pub(crate) enum RecordSchemaParseLocation {
     /// When the parse is happening inside a record field
     FromField,
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::Schema;
+    use apache_avro_test_helper::TestResult;
+    use pretty_assertions::assert_eq;
+
+    #[test]
+    fn avro_rs_403_record_schema_builder_no_fields() -> TestResult {
+        let name = Name::new("TestRecord")?;
+
+        let record_schema = RecordSchema::builder()
+            .name(name.clone())
+            .fields(vec![])

Review Comment:
   It's actually useful for dealing with Rust enums (https://github.com/apache/avro-rs/issues/365#issuecomment-3730627801)



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org