Skip to content

Commit

Permalink
Use valid schema related to null default based on specification in
Browse files Browse the repository at this point in the history
RecordEvolutionTest

during investigation upgrading Avro to 1.9+, the test was failing. the
code has enforced the rule from the specification that `when a default
value is specified for a record field whose type is a union, the type of
the default value must match the first element of the union. Thus, for
unions containing "null", the "null" is usually listed first, since the
default value of such unions is typically null.`

it was part of specification in 1.8 already
https://avro.apache.org/docs/1.8.0/spec.html#Unions , just not enforced
in the codebase.

relates to FasterXML#167

Signed-off-by: Aurélien Pupier <[email protected]>
  • Loading branch information
apupier committed Jan 5, 2024
1 parent 23f40d9 commit 473f844
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RecordEvolutionTest extends AvroTestBase
+ " \"fields\": [\n"
+ " {\n"
+ " \"name\": \"name\",\n"
+ " \"type\": [\"string\", \"null\"],\n"
+ " \"type\": [\"null\", \"string\"],\n"
+ " \"default\": null\n"
+ " },\n"
+ " {\n"
Expand All @@ -39,7 +39,7 @@ public class RecordEvolutionTest extends AvroTestBase
+ " \"fields\": [\n"
+ " {\n"
+ " \"name\": \"fullName\",\n"
+ " \"type\": [\"string\", \"null\"],\n"
+ " \"type\": [\"null\", \"string\"],\n"
+ " \"default\": null,\n"
+ " \"aliases\": [\"name\"]\n"
+ " },\n"
Expand Down

0 comments on commit 473f844

Please sign in to comment.