polars_arrow/scalar/
union.rs1use super::Scalar;
2use crate::datatypes::ArrowDataType;
3
4#[derive(Debug, Clone, PartialEq)]
6pub struct UnionScalar {
7 value: Box<dyn Scalar>,
8 type_: i8,
9 dtype: ArrowDataType,
10}
11
12impl UnionScalar {
13 #[inline]
15 pub fn new(dtype: ArrowDataType, type_: i8, value: Box<dyn Scalar>) -> Self {
16 Self {
17 value,
18 type_,
19 dtype,
20 }
21 }
22
23 #[inline]
25 pub fn value(&self) -> &Box<dyn Scalar> {
26 &self.value
27 }
28
29 #[inline]
31 pub fn type_(&self) -> i8 {
32 self.type_
33 }
34}
35
36impl Scalar for UnionScalar {
37 #[inline]
38 fn as_any(&self) -> &dyn std::any::Any {
39 self
40 }
41
42 #[inline]
43 fn is_valid(&self) -> bool {
44 true
45 }
46
47 #[inline]
48 fn dtype(&self) -> &ArrowDataType {
49 &self.dtype
50 }
51}