Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
berkaysynnada committed Apr 16, 2024
1 parent 78a83a0 commit 901c639
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
12 changes: 2 additions & 10 deletions datafusion/functions-aggregate/src/first_last.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,7 @@ impl FirstValuePhysicalExpr {
}

pub fn convert_to_last(self) -> LastValuePhysicalExpr {
let mut name = if self.name.starts_with("FIRST") {
format!("LAST{}", &self.name[5..])
} else {
format!("LAST_VALUE({})", self.expr)
};
let mut name = format!("LAST{}", &self.name[5..]);
replace_order_by_clause(&mut name);

let FirstValuePhysicalExpr {
Expand Down Expand Up @@ -585,11 +581,7 @@ impl LastValuePhysicalExpr {
}

pub fn convert_to_first(self) -> FirstValuePhysicalExpr {
let mut name = if self.name.starts_with("LAST") {
format!("FIRST{}", &self.name[4..])
} else {
format!("FIRST_VALUE({})", self.expr)
};
let mut name = format!("FIRST{}", &self.name[4..]);
replace_order_by_clause(&mut name);

let LastValuePhysicalExpr {
Expand Down
7 changes: 4 additions & 3 deletions datafusion/physical-expr/src/equivalence/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use arrow::datatypes::SchemaRef;

use datafusion_common::tree_node::{Transformed, TransformedResult, TreeNode};
use datafusion_common::{DataFusionError, Result};
use datafusion_common::{internal_err, Result};

use crate::expressions::Column;
use crate::PhysicalExpr;
Expand Down Expand Up @@ -68,8 +68,9 @@ impl ProjectionMapping {
let idx = col.index();
let matching_input_field = input_schema.field(idx);
if col.name() != matching_input_field.name() {
return Err(DataFusionError::Internal(format!("Input field name {} does not match with the projection expression {}",matching_input_field.name(),col.name())));
}
return internal_err!("Input field name {} does not match with the projection expression {}",
matching_input_field.name(),col.name())
}
let matching_input_column =
Column::new(matching_input_field.name(), idx);
Ok(Transformed::yes(Arc::new(matching_input_column)))
Expand Down

0 comments on commit 901c639

Please sign in to comment.