@@ -415,6 +415,41 @@ mod variable;
415415///
416416///```
417417///
418+ /// ## Union Encoding
419+ ///
420+ /// A union value is encoded as the type id byte followed by the row encoding of the underlying type.
421+ /// Null values are handled by the underlying type's encoding.
422+ ///
423+ /// For example, given a union of Int32 (type_id = 0) and Utf8 (type_id = 1):
424+ ///
425+ /// ```text
426+ /// ββββ¬βββββββββββββββ
427+ /// 3 β00β01β80β00β00β03β
428+ /// ββββ΄βββββββββββββββ
429+ /// β ββ signed integer encoding (non-null)
430+ /// βββββ type_id
431+ ///
432+ /// "abc" ββββ¬βββββββββββββββββββββββββββββββββ
433+ /// β01β02β'a'β'b'β'c'β00β00β00β00β00β03β
434+ /// ββββ΄βββββββββββββββββββββββββββββββββ
435+ /// β βββββ string encoding (non-null)
436+ /// βββββ type_id
437+ ///
438+ /// null Int32 ββββ¬βββββββββββββββ
439+ /// β00β00β00β00β00β00β
440+ /// ββββ΄βββββββββββββββ
441+ /// β ββ signed integer encoding (null)
442+ /// βββββ type_id
443+ ///
444+ /// null Utf8 ββββ¬βββ
445+ /// β01β00β
446+ /// ββββ΄βββ
447+ /// β ββ string encoding (null)
448+ /// βββββ type_id
449+ /// ```
450+ ///
451+ /// See [`UnionArray`] for more details on union types.
452+ ///
418453/// # Ordering
419454///
420455/// ## Float Ordering
@@ -435,6 +470,11 @@ mod variable;
435470///
436471/// The order of a given column can be reversed by negating the encoded bytes of non-null values
437472///
473+ /// ## Union Ordering
474+ ///
475+ /// Values of the same type are ordered according to the ordering of that type.
476+ /// Values of different types are ordered by their type id.
477+ ///
438478/// [COBS]: https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing
439479/// [byte stuffing]: https://en.wikipedia.org/wiki/High-Level_Data_Link_Control#Asynchronous_framing
440480#[ derive( Debug ) ]
0 commit comments