[
https://issues.apache.org/jira/browse/AVRO-1460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17861357#comment-17861357
]
José Joaquín Atria edited comment on AVRO-1460 at 7/2/24 8:46 AM:
------------------------------------------------------------------
FWIW, this seems to be documented as a feature in [the Python "Getting Started"
document|https://avro.apache.org/docs/1.11.1/getting-started-python/] (emphasis
added):
{quote}Since the field favorite_color has type [“int”, “null”], we are not
required to specify this field, as shown in the first append. Were we to omit
the required name field, an exception would be raised. _Any extra entries not
corresponding to a field are present_ _in the dict are ignored_ [sic]{_}.{_}
{quote}
If this is also a long-standing behaviour in the Ruby implementation, I think
it would be sensible to add this to all three or none, to keep the interfaces
consistent.
was (Author: JIRAUSER305792):
FWIW, this seems to be documented as a feature in [the Python "Getting Started"
document|https://avro.apache.org/docs/1.11.1/getting-started-python/] (emphasis
added):
{quote}Since the field favorite_color has type [“int”, “null”], we are not
required to specify this field, as shown in the first append. Were we to omit
the required name field, an exception would be raised. _Any extra entries not
corresponding to a field are present_ [sic] \{_}in the dict are
ignored{_}{_}.{_}
{quote}
If this is also a long-standing behaviour in the Ruby implementation, I think
it would be sensible to add this to all three or none, to keep the interfaces
consistent.
> Perl API doesn't raise warning/error when encoding record with spurious fields
> ------------------------------------------------------------------------------
>
> Key: AVRO-1460
> URL: https://issues.apache.org/jira/browse/AVRO-1460
> Project: Apache Avro
> Issue Type: Improvement
> Components: perl
> Reporter: John Karp
> Assignee: John Karp
> Priority: Minor
> Fix For: 1.9.0
>
> Attachments: AVRO-1460.patch
>
>
> When serializing a record with a field that isn't specified in the schema,
> there should be some sort of warning or error. Otherwise, a simple typo in a
> field name can lead to silent loss of that field's data.
> Test case that should pass but currently fails:
> {noformat}
> {
> my $schema = Avro::Schema->parse(<<EOJ);
> {
> "type": "record",
> "name": "test",
> "fields" : [
> {"name": "a", "type": "long"}
> ]
> }
> EOJ
> my $enc = '';
> eval {
> Avro::BinaryEncoder->encode(
> schema => $schema,
> data => { a => 27, b => 'foo' },
> emit_cb => sub { $enc .= ${ $_[0] } },
> );
> };
> isa_ok $@, 'Avro::BinaryEncoder::Error';
> }
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)