Skip to content

Commit

Permalink
Replace &Option<T> with Option<&T> (#5102)
Browse files Browse the repository at this point in the history
* replace &Option<T> with Option<&T>

* replace Option<&usize> with Option<usize>

* fix clippy error
  • Loading branch information
gaoxinge authored Jan 30, 2023
1 parent 3133526 commit 9c8bdfe
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/src/physical_plan/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ impl Metric {
}

/// return a reference to the partition
pub fn partition(&self) -> &Option<usize> {
&self.partition
pub fn partition(&self) -> Option<usize> {
self.partition
}
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/aggregate/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

/// Enum used for differenciating population and sample for statistical functions
/// Enum used for differentiating population and sample for statistical functions
#[derive(Debug, Clone, Copy)]
pub enum StatsType {
/// Population
Expand Down
4 changes: 2 additions & 2 deletions datafusion/physical-expr/src/expressions/case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ impl CaseExpr {
}

/// Optional base expression that can be compared to literal values in the "when" expressions
pub fn expr(&self) -> &Option<Arc<dyn PhysicalExpr>> {
&self.expr
pub fn expr(&self) -> Option<&Arc<dyn PhysicalExpr>> {
self.expr.as_ref()
}

/// One or more when/then expressions
Expand Down
4 changes: 2 additions & 2 deletions datafusion/physical-expr/src/window/lead_lag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl PartitionEvaluator for WindowShiftEvaluator {
let dtype = array.data_type();
let idx = self.state.idx as i64 - self.shift_offset;
if idx < 0 || idx as usize >= array.len() {
get_default_value(&self.default_value, dtype)
get_default_value(self.default_value.as_ref(), dtype)
} else {
ScalarValue::try_from_array(array, idx as usize)
}
Expand All @@ -238,7 +238,7 @@ impl PartitionEvaluator for WindowShiftEvaluator {
}

fn get_default_value(
default_value: &Option<ScalarValue>,
default_value: Option<&ScalarValue>,
dtype: &DataType,
) -> Result<ScalarValue> {
if let Some(value) = default_value {
Expand Down
1 change: 0 additions & 1 deletion datafusion/proto/src/physical_plan/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ impl TryFrom<Arc<dyn PhysicalExpr>> for protobuf::PhysicalExprNode {
protobuf::PhysicalCaseNode {
expr: expr
.expr()
.as_ref()
.map(|exp| exp.clone().try_into().map(Box::new))
.transpose()?,
when_then_expr: expr
Expand Down

0 comments on commit 9c8bdfe

Please sign in to comment.