[ 
https://issues.apache.org/jira/browse/AVRO-3483?focusedWorklogId=755057&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-755057
 ]

ASF GitHub Bot logged work on AVRO-3483:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Apr/22 23:48
            Start Date: 10/Apr/22 23:48
    Worklog Time Spent: 10m 
      Work Description: martin-g commented on code in PR #1636:
URL: https://github.com/apache/avro/pull/1636#discussion_r846866511


##########
lang/rust/avro/src/types.rs:
##########
@@ -878,15 +979,65 @@ mod tests {
                 false,
             ),
             (Value::Record(vec![]), Schema::Null, false),
+            (
+                Value::Fixed(12, vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
+                Schema::Duration,
+                true,
+            ),
+            (
+                Value::Fixed(11, vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
+                Schema::Duration,
+                false,
+            ),
+            (
+                Value::Record(vec![("unknown_field_name".to_string(), 
Value::Null)]),
+                Schema::Record {
+                    name: Name::new("record_name").unwrap(),
+                    aliases: None,
+                    doc: None,
+                    fields: vec![RecordField {
+                        name: "field_name".to_string(),
+                        doc: None,
+                        default: None,
+                        schema: Schema::Int,
+                        order: RecordFieldOrder::Ignore,
+                        position: 0,
+                    }],
+                    lookup: Default::default(),
+                },
+                false,
+            ),
+            (
+                Value::Record(vec![("field_name".to_string(), Value::Null)]),
+                Schema::Record {
+                    name: Name::new("record_name").unwrap(),
+                    aliases: None,
+                    doc: None,
+                    fields: vec![RecordField {
+                        name: "field_name".to_string(),
+                        doc: None,
+                        default: None,
+                        schema: Schema::Ref {
+                            name: Name::new("missing").unwrap(),
+                        },
+                        order: RecordFieldOrder::Ignore,
+                        position: 0,
+                    }],
+                    lookup: Default::default(),
+                },
+                false,
+            ),
         ];
 
         for (value, schema, valid) in value_schema_valid.into_iter() {
-            assert_eq!(valid, value.validate(&schema));
+            assert_eq!(valid, value.validate_internal(&schema, 
&HashMap::default()));
         }
     }
 
     #[test]
     fn validate_fixed() {
+        init();

Review Comment:
   I've implemented a custom Logger that stores the logged messages in a thread 
local Vec!
   
   > Do we need to keep them logging for other builds?
   
   You mean whether we need to log the errors at all ?
   I think it is useful because the application will most probably log them 
too, so that the developer could fix the problematic Avro records.
   
   At the moment apache_avro lib uses `log` crate APIs. The error messages are 
logged only if the application provides an Impl like `env_logger`, as we do in 
the tests





Issue Time Tracking
-------------------

    Worklog Id:     (was: 755057)
    Time Spent: 1h  (was: 50m)

> [Rust] Log error messages with a reason when the validation fails
> -----------------------------------------------------------------
>
>                 Key: AVRO-3483
>                 URL: https://issues.apache.org/jira/browse/AVRO-3483
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: rust
>            Reporter: Martin Tzvetanov Grigorov
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Currently types::Value::validate(Schema) just returns a boolean with the 
> result of the validation.
> It would be good if the Rust SDK logs the reason for a failed validation.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to