You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/08 20:26:43 UTC
[GitHub] [arrow-datafusion] andygrove commented on a diff in pull request #3101: Add SQL planner support for `Like`, `ILike` and `SimilarTo`, with optional escape character
andygrove commented on code in PR #3101:
URL: https://github.com/apache/arrow-datafusion/pull/3101#discussion_r966389952
##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -86,29 +87,45 @@ impl ExprRewriter for TypeCoercionRewriter {
}
fn mutate(&mut self, expr: Expr) -> Result<Expr> {
- match expr {
+ match &expr {
Expr::BinaryExpr { left, op, right } => {
let left_type = left.get_type(&self.schema)?;
let right_type = right.get_type(&self.schema)?;
- let coerced_type = coerce_types(&left_type, &op, &right_type)?;
+ let coerced_type = coerce_types(&left_type, op, &right_type)?;
Ok(Expr::BinaryExpr {
- left: Box::new(left.cast_to(&coerced_type, &self.schema)?),
- op,
- right: Box::new(right.cast_to(&coerced_type, &self.schema)?),
+ left: Box::new(
+ left.as_ref().clone().cast_to(&coerced_type, &self.schema)?,
+ ),
+ op: *op,
+ right: Box::new(
+ right
+ .as_ref()
+ .clone()
+ .cast_to(&coerced_type, &self.schema)?,
+ ),
})
}
+ Expr::Like { pattern, .. }
+ | Expr::ILike { pattern, .. }
+ | Expr::SimilarTo { pattern, .. } => match pattern.get_type(&self.schema)? {
+ DataType::Utf8 => Ok(expr.clone()),
Review Comment:
This is for the regular expression pattern, which is typically a literal string but could, in theory, be a column reference. I'm not sure if it would make sense to support LargeUtf8 here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org