@@ -552,7 +552,7 @@ the world. If this is not practical for you, use explicit field ids, which
552
552
should always generate a merge conflict if two people try to allocate the same
553
553
id.
554
554
555
- ### Schema evolution examples
555
+ ### Schema evolution examples (tables)
556
556
557
557
Some examples to clarify what happens as you change a schema:
558
558
@@ -614,6 +614,41 @@ Occasionally ok. You've renamed fields, which will break all code (and JSON
614
614
files!) that use this schema, but as long as the change is obvious, this is not
615
615
incompatible with the actual binary buffers, since those only ever address
616
616
fields by id/offset.
617
+
618
+ #### Schema evolution examples (unions)
619
+
620
+ Suppose we have the following schema:
621
+ ```
622
+ union Foo { A, B }
623
+ ```
624
+ We can add another variant at the end.
625
+ ```
626
+ union Foo { A, B, another_a: A }
627
+ ```
628
+ and this will be okay. Old code will not recognize ` another_a ` .
629
+ However if we add ` another_a ` anywhere but the end, e.g.
630
+ ```
631
+ union Foo { A, another_a: A, B }
632
+ ```
633
+ this is not okay. When new code writes ` another_a ` , old code will
634
+ misinterpret it as ` B ` (and vice versa). However you can explicitly
635
+ set the union's "discriminant" value like so:
636
+ ```
637
+ union Foo { A = 1, another_a: A = 3, B = 2 }
638
+ ```
639
+ This is okay.
640
+
641
+ ```
642
+ union Foo { original_a: A = 1, another_a: A = 3, B = 2 }
643
+ ```
644
+ Renaming fields will break code and any saved human readable representations,
645
+ such as json files, but the binary buffers will be the same.
646
+
647
+
648
+
649
+
650
+
651
+
617
652
<br >
618
653
619
654
### Testing whether a field is present in a table
0 commit comments