Skip to content

Commit

Permalink
remove more allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
erratic-pattern committed May 11, 2024
1 parent 92ae104 commit 1ead25c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 8 additions & 12 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1700,17 +1700,15 @@ fn write_name<W: Write>(w: &mut W, e: &Expr) -> Result<()> {
}) => {
write!(
w,
"{} {}{} {} {}",
"{} {}{} {}",
expr,
if *negated { "NOT " } else { "" },
if *case_insensitive { "ILIKE" } else { "LIKE" },
pattern,
if let Some(char) = escape_char {
format!("CHAR '{char}'")
} else {
"".to_owned()
}
)?;
if let Some(char) = escape_char {
write!(w, " CHAR '{char}'")?;
}
}
Expr::SimilarTo(Like {
negated,
Expand All @@ -1721,20 +1719,18 @@ fn write_name<W: Write>(w: &mut W, e: &Expr) -> Result<()> {
}) => {
write!(
w,
"{} {} {} {}",
"{} {} {}",
expr,
if *negated {
"NOT SIMILAR TO"
} else {
"SIMILAR TO"
},
pattern,
if let Some(char) = escape_char {
format!("CHAR '{char}'")
} else {
"".to_owned()
}
)?;
if let Some(char) = escape_char {
write!(w, " CHAR '{char}'")?;
}
}
Expr::Case(case) => {
write!(w, "CASE ")?;
Expand Down
4 changes: 2 additions & 2 deletions datafusion/optimizer/src/analyzer/type_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ mod test {
let like_expr = Expr::Like(Like::new(false, expr, pattern, None, false));
let empty = empty_with_type(DataType::Utf8);
let plan = LogicalPlan::Projection(Projection::try_new(vec![like_expr], empty)?);
let expected = "Projection: a LIKE CAST(NULL AS Utf8) AS a LIKE NULL \
let expected = "Projection: a LIKE CAST(NULL AS Utf8) AS a LIKE NULL\
\n EmptyRelation";
assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)?;

Expand Down Expand Up @@ -1158,7 +1158,7 @@ mod test {
let ilike_expr = Expr::Like(Like::new(false, expr, pattern, None, true));
let empty = empty_with_type(DataType::Utf8);
let plan = LogicalPlan::Projection(Projection::try_new(vec![ilike_expr], empty)?);
let expected = "Projection: a ILIKE CAST(NULL AS Utf8) AS a ILIKE NULL \
let expected = "Projection: a ILIKE CAST(NULL AS Utf8) AS a ILIKE NULL\
\n EmptyRelation";
assert_analyzed_plan_eq(Arc::new(TypeCoercion::new()), plan, expected)?;

Expand Down

0 comments on commit 1ead25c

Please sign in to comment.