| 961 | |
| 962 | impl std::fmt::Debug for UnionArray { |
| 963 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { |
| 964 | let header = if self.is_dense() { |
| 965 | "UnionArray(Dense)\n[" |
| 966 | } else { |
| 967 | "UnionArray(Sparse)\n[" |
| 968 | }; |
| 969 | writeln!(f, "{header}")?; |
| 970 | |
| 971 | writeln!(f, "-- type id buffer:")?; |
| 972 | writeln!(f, "{:?}", self.type_ids)?; |
| 973 | |
| 974 | if let Some(offsets) = &self.offsets { |
| 975 | writeln!(f, "-- offsets buffer:")?; |
| 976 | writeln!(f, "{offsets:?}")?; |
| 977 | } |
| 978 | |
| 979 | let fields = match self.data_type() { |
| 980 | DataType::Union(fields, _) => fields, |
| 981 | _ => unreachable!(), |
| 982 | }; |
| 983 | |
| 984 | for (type_id, field) in fields.iter() { |
| 985 | let child = self.child(type_id); |
| 986 | writeln!( |
| 987 | f, |
| 988 | "-- child {}: \"{}\" ({:?})", |
| 989 | type_id, |
| 990 | field.name(), |
| 991 | field.data_type() |
| 992 | )?; |
| 993 | std::fmt::Debug::fmt(child, f)?; |
| 994 | writeln!(f)?; |
| 995 | } |
| 996 | writeln!(f, "]") |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | /// How to compute the logical nulls of a sparse union. All strategies return the same result. |