Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl Debug for ColumnarValue, add some docs #3076

Merged
merged 2 commits into from
Aug 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions datafusion/expr/src/columnar_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ use arrow::record_batch::RecordBatch;
use datafusion_common::ScalarValue;
use std::sync::Arc;

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

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