Skip to content

Commit 31381bf

Browse files
authored
impl Debug for ColumnarValue, add some docs (#3076)
1 parent 85d5363 commit 31381bf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

datafusion/expr/src/columnar_value.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ use arrow::record_batch::RecordBatch;
2424
use datafusion_common::ScalarValue;
2525
use std::sync::Arc;
2626

27-
/// Represents the result from an expression
28-
#[derive(Clone)]
27+
/// Represents the result of evaluating an expression: either a single
28+
/// `ScalarValue` or an [`ArrayRef`].
29+
///
30+
/// While a [`ColumnarValue`] can always be converted into an array
31+
/// for convenience, it is often much more performant to provide an
32+
/// optimized path for scalar values.
33+
#[derive(Clone, Debug)]
2934
pub enum ColumnarValue {
3035
/// Array of values
3136
Array(ArrayRef),
@@ -41,7 +46,8 @@ impl ColumnarValue {
4146
}
4247
}
4348

44-
/// Convert a columnar value into an ArrayRef
49+
/// Convert a columnar value into an ArrayRef. [`Self::Scalar`] is
50+
/// converted by repeating the same scalar multiple times.
4551
pub fn into_array(self, num_rows: usize) -> ArrayRef {
4652
match self {
4753
ColumnarValue::Array(array) => array,

0 commit comments

Comments
 (0)