You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Kriskras99 (via GitHub)" <gi...@apache.org> on 2025/12/04 14:15:12 UTC

[PR] test: Different field order between Serde and the Schema [avro-rs]

Kriskras99 opened a new pull request, #351:
URL: https://github.com/apache/avro-rs/pull/351

   This is a (failing) test for when the field order differs between the struct (Serde) and the schema:
   ```
   The application panicked (crashed).
     assertion `left == right` failed
       left: Foo { a: "World", b: "Hello" }
      right: Foo { a: "Hello", b: "World" }
   in avro/src/ser_schema.rs, line 2940
   thread: ser_schema::tests::different_field_order_serde_vs_schema
   ```
   
   There are two options:
   
   - Require that the field order is the same
   - Modify `ser_schema.rs` (and potentially `de.rs`) to care about the field order


-- 
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: Don't depend on Serde to provide fields in the right order [avro-rs]

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


##########
avro/src/ser_schema.rs:
##########
@@ -249,6 +249,9 @@ impl<W: Write> ser::SerializeMap for SchemaAwareWriteSerializeMap<'_, '_, W> {
 pub struct SchemaAwareWriteSerializeStruct<'a, 's, W: Write> {
     ser: &'a mut SchemaAwareWriteSerializer<'s, W>,
     record_schema: &'s RecordSchema,
+    /// Fields we received in the wrong order
+    field_cache: Vec<(usize, Vec<u8>)>,
+    next_field: usize,

Review Comment:
   ```suggestion
       field_position: usize,
   ```
   I think this will be a better self-documenting name



##########
avro/src/ser_schema.rs:
##########
@@ -268,19 +273,86 @@ impl<'a, 's, W: Write> SchemaAwareWriteSerializeStruct<'a, 's, W> {
     where
         T: ?Sized + ser::Serialize,
     {
-        // If we receive fields in order, write them directly to the main writer
-        let mut value_ser = SchemaAwareWriteSerializer::new(
-            &mut *self.ser.writer,
-            &field.schema,
-            self.ser.names,
-            self.ser.enclosing_namespace.clone(),
-        );
-        self.bytes_written += value.serialize(&mut value_ser)?;
+        if field.position == self.next_field {
+            // If we receive fields in order, write them directly to the main writer
+            let mut value_ser = SchemaAwareWriteSerializer::new(
+                &mut *self.ser.writer,
+                &field.schema,
+                self.ser.names,
+                self.ser.enclosing_namespace.clone(),
+            );
+            self.bytes_written += value.serialize(&mut value_ser)?;
 
+            self.next_field += 1;
+            while let Some(index) = self
+                .field_cache
+                .iter()
+                .position(|(pos, _)| pos == &self.next_field)
+            {
+                let (_, bytes) = self.field_cache.remove(index);
+                self.ser
+                    .writer
+                    .write_all(&bytes)
+                    .map_err(Details::WriteBytes)?;
+                self.bytes_written += bytes.len();
+                self.next_field += 1;
+            }
+        } else {
+            // This field is in the wrong order, write it to a temporary buffer so we can add it at the right time
+            let mut bytes = Vec::new();
+            let mut value_ser = SchemaAwareWriteSerializer::new(
+                &mut bytes,
+                &field.schema,
+                self.ser.names,
+                self.ser.enclosing_namespace.clone(),
+            );
+            value.serialize(&mut value_ser)?;
+            self.field_cache.push((field.position, bytes));
+        }
         Ok(())
     }
 
-    fn end(self) -> Result<usize, Error> {
+    fn end(mut self) -> Result<usize, Error> {
+        // Write any fields that are `serde(skip)` or `serde(skip_serializing)`
+        while self.next_field != self.record_schema.fields.len() {
+            let field_info = &self.record_schema.fields[self.next_field];
+            if let Some(index) = self
+                .field_cache
+                .iter()
+                .position(|(pos, _)| pos == &self.next_field)
+            {
+                let (_, bytes) = self.field_cache.remove(index);
+                self.ser
+                    .writer
+                    .write_all(&bytes)
+                    .map_err(Details::WriteBytes)?;
+                self.bytes_written += bytes.len();
+                self.next_field += 1;
+            } else if let Some(default) = &field_info.default {
+                self.serialize_next_field(field_info, default)
+                    .map_err(|e| Details::SerializeRecordFieldWithSchema {
+                        field_name: field_info.name.clone(),
+                        record_schema: Schema::Record(self.record_schema.clone()),
+                        error: Box::new(e),
+                    })?;
+            } else {
+                return Err(Details::MissingDefaultForSkippedField {
+                    field_name: field_info.name.clone(),
+                    schema: Schema::Record(self.record_schema.clone()),
+                }
+                .into());
+            }
+        }
+
+        // Check if all fields were written
+        if self.next_field != self.record_schema.fields.len() {
+            let name = self.record_schema.fields[self.next_field].name.clone();
+            return Err(Details::GetField(name).into());
+        }
+        assert!(
+            self.field_cache.is_empty(),
+            "There should be no more unwritten fields at this point"

Review Comment:
   Let's print the contents of `self.field_cache` for easier debugging.



##########
avro/src/ser_schema.rs:
##########
@@ -249,6 +249,9 @@ impl<W: Write> ser::SerializeMap for SchemaAwareWriteSerializeMap<'_, '_, W> {
 pub struct SchemaAwareWriteSerializeStruct<'a, 's, W: Write> {
     ser: &'a mut SchemaAwareWriteSerializer<'s, W>,
     record_schema: &'s RecordSchema,
+    /// Fields we received in the wrong order
+    field_cache: Vec<(usize, Vec<u8>)>,

Review Comment:
   Why a Vec ? Wouldn't it be simpler with a `HashMap<usize, Vec<u8>>` ?



##########
avro/src/ser_schema.rs:
##########
@@ -2900,4 +2978,50 @@ mod tests {
         string_record.serialize(&mut serializer)?;
         Ok(())
     }
+
+    #[test]
+    fn different_field_order_serde_vs_schema() -> TestResult {

Review Comment:
   ```suggestion
       fn avro_rs_351_different_field_order_serde_vs_schema() -> TestResult {
   ```



##########
avro/tests/avro-rs-226.rs:
##########
@@ -128,3 +133,69 @@ fn avro_rs_226_index_out_of_bounds_with_serde_skip_multiple_fields() -> TestResu
         },
     )
 }
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'y' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_serializing_if_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        x: Option<i8>,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        y: Option<String>,
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: None,
+            y: None,
+            z: Some(1),
+        },
+    )
+    .unwrap()
+}
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'x' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        #[serde(skip)]
+        x: Option<i8>,
+        y: Option<String>,
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: None,
+            y: None,
+            z: Some(1),
+        },
+    )
+    .unwrap()
+}
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'z' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_serializing_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        x: Option<i8>,
+        y: Option<String>,
+        #[serde(skip_serializing)]
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: Some(0),
+            y: None,
+            z: None,
+        },
+    )
+    .unwrap()

Review Comment:
   Let's use `TestResult` return type and avoid using `.unwrap()`.



##########
avro/tests/avro-rs-226.rs:
##########
@@ -128,3 +133,69 @@ fn avro_rs_226_index_out_of_bounds_with_serde_skip_multiple_fields() -> TestResu
         },
     )
 }
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'y' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_serializing_if_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        x: Option<i8>,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        y: Option<String>,
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: None,
+            y: None,
+            z: Some(1),
+        },
+    )
+    .unwrap()

Review Comment:
   Let's use `TestResult` return type and avoid using `.unwrap()`.



##########
avro/src/ser_schema.rs:
##########
@@ -2900,4 +2978,50 @@ mod tests {
         string_record.serialize(&mut serializer)?;
         Ok(())
     }
+
+    #[test]
+    fn different_field_order_serde_vs_schema() -> TestResult {
+        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+        struct Foo {
+            a: String,
+            b: String,
+        }
+        let schema = Schema::parse_str(
+            r#"
+        {
+            "type":"record",
+            "name":"Foo",
+            "fields": [
+                {
+                    "name":"b",
+                    "type":"string"
+                },
+                {
+                    "name":"a",
+                    "type":"string"
+                }
+            ]
+        }
+        "#,
+        )?;
+
+        let mut writer = Writer::new(&schema, Vec::new())?;
+        if let Err(e) = writer.append_ser(Foo {
+            a: "Hello".into(),
+            b: "World".into(),
+        }) {
+            panic!("{e:?}");

Review Comment:
   You can use 'append_ser(...)?'. The method returns `TestResult`



##########
avro/src/ser_schema.rs:
##########
@@ -2900,4 +2978,50 @@ mod tests {
         string_record.serialize(&mut serializer)?;
         Ok(())
     }
+
+    #[test]
+    fn different_field_order_serde_vs_schema() -> TestResult {
+        #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+        struct Foo {
+            a: String,
+            b: String,

Review Comment:
   Let's make a struct with at least 5 fields. Just to make it a bit more real.



##########
avro/tests/avro-rs-226.rs:
##########
@@ -128,3 +133,69 @@ fn avro_rs_226_index_out_of_bounds_with_serde_skip_multiple_fields() -> TestResu
         },
     )
 }
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'y' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_serializing_if_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        x: Option<i8>,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        y: Option<String>,
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: None,
+            y: None,
+            z: Some(1),
+        },
+    )
+    .unwrap()
+}
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'x' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        #[serde(skip)]
+        x: Option<i8>,
+        y: Option<String>,
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: None,
+            y: None,
+            z: Some(1),
+        },
+    )
+    .unwrap()

Review Comment:
   Let's use `TestResult` return type and avoid using `.unwrap()`.



-- 
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: Don't depend on Serde to provide fields in the right order [avro-rs]

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


##########
avro/tests/avro-rs-226.rs:
##########
@@ -128,3 +133,69 @@ fn avro_rs_226_index_out_of_bounds_with_serde_skip_multiple_fields() -> TestResu
         },
     )
 }
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'y' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_serializing_if_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        x: Option<i8>,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        y: Option<String>,
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: None,
+            y: None,
+            z: Some(1),
+        },
+    )
+    .unwrap()

Review Comment:
   I see.



##########
avro/src/ser_schema.rs:
##########
@@ -268,19 +273,79 @@ impl<'a, 's, W: Write> SchemaAwareWriteSerializeStruct<'a, 's, W> {
     where
         T: ?Sized + ser::Serialize,
     {
-        // If we receive fields in order, write them directly to the main writer
-        let mut value_ser = SchemaAwareWriteSerializer::new(
-            &mut *self.ser.writer,
-            &field.schema,
-            self.ser.names,
-            self.ser.enclosing_namespace.clone(),
-        );
-        self.bytes_written += value.serialize(&mut value_ser)?;
+        if field.position == self.field_position {
+            // If we receive fields in order, write them directly to the main writer
+            let mut value_ser = SchemaAwareWriteSerializer::new(
+                &mut *self.ser.writer,
+                &field.schema,
+                self.ser.names,
+                self.ser.enclosing_namespace.clone(),
+            );
+            self.bytes_written += value.serialize(&mut value_ser)?;
 
+            self.field_position += 1;
+            while let Some(bytes) = self.field_cache.remove(&self.field_position) {
+                self.ser
+                    .writer
+                    .write_all(&bytes)
+                    .map_err(Details::WriteBytes)?;
+                self.bytes_written += bytes.len();
+                self.field_position += 1;
+            }
+        } else {
+            // This field is in the wrong order, write it to a temporary buffer so we can add it at the right time
+            let mut bytes = Vec::new();
+            let mut value_ser = SchemaAwareWriteSerializer::new(
+                &mut bytes,
+                &field.schema,
+                self.ser.names,
+                self.ser.enclosing_namespace.clone(),
+            );
+            value.serialize(&mut value_ser)?;
+            if self.field_cache.insert(field.position, bytes).is_some() {
+                return Err(Details::FieldNameDuplicate(field.name.clone()).into());
+            }
+        }
         Ok(())
     }
 
-    fn end(self) -> Result<usize, Error> {
+    fn end(mut self) -> Result<usize, Error> {
+        // Write any fields that are `serde(skip)` or `serde(skip_serializing)`
+        while self.field_position != self.record_schema.fields.len() {
+            let field_info = &self.record_schema.fields[self.field_position];
+            if let Some(bytes) = self.field_cache.remove(&self.field_position) {
+                self.ser
+                    .writer
+                    .write_all(&bytes)
+                    .map_err(Details::WriteBytes)?;
+                self.bytes_written += bytes.len();
+                self.field_position += 1;
+            } else if let Some(default) = &field_info.default {
+                self.serialize_next_field(field_info, default)
+                    .map_err(|e| Details::SerializeRecordFieldWithSchema {
+                        field_name: field_info.name.clone(),
+                        record_schema: Schema::Record(self.record_schema.clone()),
+                        error: Box::new(e),
+                    })?;
+            } else {
+                return Err(Details::MissingDefaultForSkippedField {
+                    field_name: field_info.name.clone(),
+                    schema: Schema::Record(self.record_schema.clone()),
+                }
+                .into());
+            }
+        }
+
+        // Check if all fields were written
+        if self.field_position != self.record_schema.fields.len() {

Review Comment:
   Is this check really needed ?
   The `while` above makes sure of it or returns an Err.



##########
avro/src/ser_schema.rs:
##########
@@ -268,19 +273,79 @@ impl<'a, 's, W: Write> SchemaAwareWriteSerializeStruct<'a, 's, W> {
     where
         T: ?Sized + ser::Serialize,
     {
-        // If we receive fields in order, write them directly to the main writer
-        let mut value_ser = SchemaAwareWriteSerializer::new(
-            &mut *self.ser.writer,
-            &field.schema,
-            self.ser.names,
-            self.ser.enclosing_namespace.clone(),
-        );
-        self.bytes_written += value.serialize(&mut value_ser)?;
+        if field.position == self.field_position {
+            // If we receive fields in order, write them directly to the main writer
+            let mut value_ser = SchemaAwareWriteSerializer::new(
+                &mut *self.ser.writer,
+                &field.schema,
+                self.ser.names,
+                self.ser.enclosing_namespace.clone(),
+            );
+            self.bytes_written += value.serialize(&mut value_ser)?;
 
+            self.field_position += 1;
+            while let Some(bytes) = self.field_cache.remove(&self.field_position) {
+                self.ser
+                    .writer
+                    .write_all(&bytes)
+                    .map_err(Details::WriteBytes)?;
+                self.bytes_written += bytes.len();
+                self.field_position += 1;
+            }
+        } else {
+            // This field is in the wrong order, write it to a temporary buffer so we can add it at the right time
+            let mut bytes = Vec::new();
+            let mut value_ser = SchemaAwareWriteSerializer::new(
+                &mut bytes,
+                &field.schema,
+                self.ser.names,
+                self.ser.enclosing_namespace.clone(),
+            );
+            value.serialize(&mut value_ser)?;
+            if self.field_cache.insert(field.position, bytes).is_some() {
+                return Err(Details::FieldNameDuplicate(field.name.clone()).into());
+            }
+        }
         Ok(())
     }
 
-    fn end(self) -> Result<usize, Error> {
+    fn end(mut self) -> Result<usize, Error> {
+        // Write any fields that are `serde(skip)` or `serde(skip_serializing)`
+        while self.field_position != self.record_schema.fields.len() {
+            let field_info = &self.record_schema.fields[self.field_position];
+            if let Some(bytes) = self.field_cache.remove(&self.field_position) {
+                self.ser
+                    .writer
+                    .write_all(&bytes)
+                    .map_err(Details::WriteBytes)?;
+                self.bytes_written += bytes.len();
+                self.field_position += 1;
+            } else if let Some(default) = &field_info.default {
+                self.serialize_next_field(field_info, default)
+                    .map_err(|e| Details::SerializeRecordFieldWithSchema {
+                        field_name: field_info.name.clone(),
+                        record_schema: Schema::Record(self.record_schema.clone()),
+                        error: Box::new(e),
+                    })?;
+            } else {
+                return Err(Details::MissingDefaultForSkippedField {
+                    field_name: field_info.name.clone(),
+                    schema: Schema::Record(self.record_schema.clone()),
+                }
+                .into());
+            }
+        }
+
+        // Check if all fields were written
+        if self.field_position != self.record_schema.fields.len() {
+            let name = self.record_schema.fields[self.field_position].name.clone();
+            return Err(Details::GetField(name).into());
+        }
+        assert!(

Review Comment:
   I am not sure about that.
   A library should try to avoid panicking if possible.
   I think `debug_assert!()` or returning an Err is better.



-- 
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: Don't depend on Serde to provide fields in the right order [avro-rs]

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


-- 
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: Don't depend on Serde to provide fields in the right order [avro-rs]

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

   The `match self.field_position.cmp(&field.position)` was suggested by clippy, please let me know if you don't like it. Then I'll revert to `if/else if/else` and add an `#[allow]`.


-- 
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] test: Different field order between Serde and the Schema [avro-rs]

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

   Fixed, CI will still fail as the test does fail and we need to decide what the right course of action 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] test: Different field order between Serde and the Schema [avro-rs]

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

   Please fix the formatting issue.


-- 
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: Don't depend on Serde to provide fields in the right order [avro-rs]

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


##########
avro/tests/avro-rs-226.rs:
##########
@@ -128,3 +133,69 @@ fn avro_rs_226_index_out_of_bounds_with_serde_skip_multiple_fields() -> TestResu
         },
     )
 }
+
+#[test]
+#[should_panic(expected = "Missing default for skipped field 'y' for schema")]
+fn avro_rs_351_no_default_for_serde_skip_serializing_if_should_panic() {
+    #[derive(AvroSchema, Clone, Debug, Deserialize, PartialEq, Serialize)]
+    struct T {
+        x: Option<i8>,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        y: Option<String>,
+        z: Option<i8>,
+    }
+
+    ser_deser::<T>(
+        &T::get_schema(),
+        T {
+            x: None,
+            y: None,
+            z: Some(1),
+        },
+    )
+    .unwrap()

Review Comment:
   That doesn't work. `ser_deser` is supposed to error and because creating a TestResult is the same as panicking I need to check the panic message.
   If I add a `-> TestResult` and return `Ok(())` clippy complains that my should_panic test should not have a return type.



-- 
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] test: Different field order between Serde and the Schema [avro-rs]

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

   > we need to decide what the right course of action is
   
   I won't have time to debug it in the next days but I was going to bet that we probably don't use the `lookup` map but we do - https://github.com/apache/avro-rs/blob/335e74edcfaf204e504d412bba0b52129603bc20/avro/src/ser_schema.rs#L298-L299
   So, it must be something else.


-- 
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] test: Different field order between Serde and the Schema [avro-rs]

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

   The lookup is only used to find the field information from the name.
   After that, the field is just written as there is no buffering for unordered fields.
   I can write a fix for that, or we can decide that the Serde field order must match the Schema field order (and add that to the docs).


-- 
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: Don't depend on Serde to provide fields in the right order [avro-rs]

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

   I've added support for out-of-order fields in the serializer. In the deserializer no changed are necessary.
   This changes test introduced in #227 as an `#[avro(default = ...)]` is now required when using any of the Serde `skip` attributes. I'm also working on a PR to check the Serde attributes in avro-derive (and add documentation for the attributes avro-derive supports as they don't seem to be documented anywhere).


-- 
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: Don't depend on Serde to provide fields in the right order [avro-rs]

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

   I've downgraded it to a debug_assert and added an extra check in `serialize_next_field` so that it should never trigger it all.
   I do think we should keep the debug_assert, because it has no performance impact but if the situation does happen it prevents data corruption.


-- 
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