You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2023/01/30 06:16:53 UTC
[arrow-datafusion] branch master updated: Replace &Option with Option<&T> (#5102)
This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new 9c8bdfed1 Replace &Option<T> with Option<&T> (#5102)
9c8bdfed1 is described below
commit 9c8bdfed1a51fd17e28dc1d7eb494844551a204b
Author: gaoxinge <ga...@gmail.com>
AuthorDate: Mon Jan 30 14:16:47 2023 +0800
Replace &Option<T> with Option<&T> (#5102)
* replace &Option<T> with Option<&T>
* replace Option<&usize> with Option<usize>
* fix clippy error
---
datafusion/core/src/physical_plan/metrics/mod.rs | 4 ++--
datafusion/physical-expr/src/aggregate/stats.rs | 2 +-
datafusion/physical-expr/src/expressions/case.rs | 4 ++--
datafusion/physical-expr/src/window/lead_lag.rs | 4 ++--
datafusion/proto/src/physical_plan/to_proto.rs | 1 -
5 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/datafusion/core/src/physical_plan/metrics/mod.rs b/datafusion/core/src/physical_plan/metrics/mod.rs
index ca32cc960..ebaec48e7 100644
--- a/datafusion/core/src/physical_plan/metrics/mod.rs
+++ b/datafusion/core/src/physical_plan/metrics/mod.rs
@@ -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
}
}
diff --git a/datafusion/physical-expr/src/aggregate/stats.rs b/datafusion/physical-expr/src/aggregate/stats.rs
index 3f2d26662..98baaccff 100644
--- a/datafusion/physical-expr/src/aggregate/stats.rs
+++ b/datafusion/physical-expr/src/aggregate/stats.rs
@@ -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
diff --git a/datafusion/physical-expr/src/expressions/case.rs b/datafusion/physical-expr/src/expressions/case.rs
index c4150e6cb..3dff4ae97 100644
--- a/datafusion/physical-expr/src/expressions/case.rs
+++ b/datafusion/physical-expr/src/expressions/case.rs
@@ -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
diff --git a/datafusion/physical-expr/src/window/lead_lag.rs b/datafusion/physical-expr/src/window/lead_lag.rs
index fc815a220..794c7bd39 100644
--- a/datafusion/physical-expr/src/window/lead_lag.rs
+++ b/datafusion/physical-expr/src/window/lead_lag.rs
@@ -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)
}
@@ -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 {
diff --git a/datafusion/proto/src/physical_plan/to_proto.rs b/datafusion/proto/src/physical_plan/to_proto.rs
index 653baec99..a987e7fee 100644
--- a/datafusion/proto/src/physical_plan/to_proto.rs
+++ b/datafusion/proto/src/physical_plan/to_proto.rs
@@ -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