Skip to content

Commit 87a84f9

Browse files
committed
rename column and address comment
1 parent f5f5869 commit 87a84f9

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Diff for: datafusion/physical-expr/src/partitioning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub enum Partitioning {
120120
/// Allocate rows based on a hash of one of more expressions and the specified number
121121
/// of partitions with a selection vecotr column.
122122
///
123-
/// The column is a boolean column called `selection` that is used to filter out rows
123+
/// The column is a boolean column called `__selection` that is used to filter out rows
124124
/// that should not be included in the partition. `true` means the row should be included
125125
/// and `false` means the row should be excluded.
126126
HashSelectionVector(Vec<Arc<dyn PhysicalExpr>>, usize),

Diff for: datafusion/physical-plan/src/repartition/mod.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ use crate::sorts::streaming_merge::StreamingMergeBuilder;
4040
use crate::stream::RecordBatchStreamAdapter;
4141
use crate::{DisplayFormatType, ExecutionPlan, Partitioning, PlanProperties, Statistics};
4242

43-
use arrow::array::{
44-
ArrayRef, BooleanArray, PrimitiveArray, RecordBatch, RecordBatchOptions,
45-
};
43+
use arrow::array::{BooleanArray, PrimitiveArray, RecordBatch, RecordBatchOptions};
4644
use arrow::compute::take_arrays;
4745
use arrow::datatypes::{SchemaRef, UInt32Type};
4846
use arrow_schema::{DataType, Field};
@@ -204,7 +202,7 @@ enum BatchPartitionerState {
204202
},
205203
}
206204

207-
pub static SELECTION_FILED_NAME: &str = "selection";
205+
pub static SELECTION_FILED_NAME: &str = "__selection";
208206

209207
impl BatchPartitioner {
210208
/// Create a new [`BatchPartitioner`] with the provided [`Partitioning`]
@@ -379,15 +377,15 @@ impl BatchPartitioner {
379377
let it = (0..*num_partitions).map(move |partition| {
380378
// Tracking time required for repartitioned batches construction
381379
let _timer = partitioner_timer.timer();
382-
let select_vector = hash_vector
383-
.iter()
384-
.map(|&hash| hash == partition as u64)
385-
.collect::<Vec<_>>();
386-
let new_col: ArrayRef =
387-
Arc::new(BooleanArray::from(select_vector)) as ArrayRef;
380+
let selection_vector = Arc::new(
381+
hash_vector
382+
.iter()
383+
.map(|&hash| Some(hash == partition as u64))
384+
.collect::<BooleanArray>(),
385+
);
388386
let mut columns =
389387
batch.columns().iter().map(Arc::clone).collect::<Vec<_>>();
390-
columns.push(new_col);
388+
columns.push(selection_vector);
391389
let mut options = RecordBatchOptions::new();
392390
options = options.with_row_count(Some(batch.num_rows()));
393391
let batch = RecordBatch::try_new_with_options(

0 commit comments

Comments
 (0)