This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 4170872 feat: use str args rather than String in transform (#325)
4170872 is described below
commit 41708725114ee6aa054989bbc21dc8b8f4eb461d
Author: Scott Donnelly <[email protected]>
AuthorDate: Mon Apr 15 14:45:25 2024 +0100
feat: use str args rather than String in transform (#325)
---
crates/iceberg/src/spec/transform.rs | 10 +++++-----
crates/iceberg/src/transform/mod.rs | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/crates/iceberg/src/spec/transform.rs
b/crates/iceberg/src/spec/transform.rs
index bdddd32..4cc1ffe 100644
--- a/crates/iceberg/src/spec/transform.rs
+++ b/crates/iceberg/src/spec/transform.rs
@@ -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 {
@@ -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),
@@ -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>> {
@@ -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>,
@@ -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
diff --git a/crates/iceberg/src/transform/mod.rs
b/crates/iceberg/src/transform/mod.rs
index 84e213e..b515666 100644
--- a/crates/iceberg/src/transform/mod.rs
+++ b/crates/iceberg/src/transform/mod.rs
@@ -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()),