Skip to content

Commit

Permalink
feat: use str args rather than String in transform (apache#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdd authored Apr 15, 2024
1 parent ca9de89 commit 4170872
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions crates/iceberg/src/spec/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl Transform {
/// `bucket(a, 37) as bs`, if one row matches `a = 10`, then its partition
/// value should match `bucket(10, 37) as bs`, and we project `a = 10` to
/// `bs = bucket(10, 37)`
pub fn project(&self, name: String, predicate: &BoundPredicate) -> Result<Option<Predicate>> {
pub fn project(&self, name: &str, predicate: &BoundPredicate) -> Result<Option<Predicate>> {
let func = create_transform_function(self)?;

match self {
Expand Down Expand Up @@ -335,7 +335,7 @@ impl Transform {
}

/// Creates a unary predicate from a given operator and a reference name.
fn project_unary(op: PredicateOperator, name: String) -> Result<Option<Predicate>> {
fn project_unary(op: PredicateOperator, name: &str) -> Result<Option<Predicate>> {
Ok(Some(Predicate::Unary(UnaryExpression::new(
op,
Reference::new(name),
Expand All @@ -350,7 +350,7 @@ impl Transform {
/// `Predicate::Binary`variant representing the binary operation.
fn project_eq_operator(
&self,
name: String,
name: &str,
expr: &BinaryExpression<BoundReference>,
func: &BoxedTransformFunction,
) -> Result<Option<Predicate>> {
Expand All @@ -375,7 +375,7 @@ impl Transform {
/// inclusive variant.
fn project_binary_with_adjusted_boundary(
&self,
name: String,
name: &str,
expr: &BinaryExpression<BoundReference>,
func: &BoxedTransformFunction,
width: Option<u32>,
Expand Down Expand Up @@ -423,7 +423,7 @@ impl Transform {
fn project_in_operator(
&self,
expr: &SetExpression<BoundReference>,
name: String,
name: &str,
func: &BoxedTransformFunction,
) -> Result<Option<Predicate>> {
if expr.op() != PredicateOperator::In
Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod test {
predicate: &BoundPredicate,
expected: Option<&str>,
) -> Result<()> {
let result = self.transform.project(self.name.clone(), predicate)?;
let result = self.transform.project(&self.name, predicate)?;
match expected {
Some(exp) => assert_eq!(format!("{}", result.unwrap()), exp),
None => assert!(result.is_none()),
Expand Down

0 comments on commit 4170872

Please sign in to comment.