Jefffrey commented on code in PR #22887:
URL: https://github.com/apache/datafusion/pull/22887#discussion_r3426745459
##########
datafusion/sql/src/expr/mod.rs:
##########
@@ -927,7 +927,10 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
) -> Result<Expr> {
let pattern = self.sql_expr_to_logical_expr(pattern, schema,
planner_context)?;
let pattern_type = pattern.get_type(schema)?;
- if pattern_type != DataType::Utf8 && pattern_type != DataType::Null {
+ if !matches!(
Review Comment:
can use
[`DataType::is_string`](https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html#method.is_string)
here, though I wonder if we should be allowing dictionaries here too?
##########
datafusion/optimizer/src/analyzer/type_coercion.rs:
##########
@@ -613,6 +613,33 @@ impl TreeNodeRewriter for TypeCoercionRewriter<'_> {
case_insensitive,
))))
}
+ Expr::SimilarTo(Like {
+ negated,
+ expr,
+ pattern,
+ escape_char,
+ case_insensitive,
+ }) => {
+ let left_type = expr.get_type(self.schema)?;
+ let right_type = pattern.get_type(self.schema)?;
+ let coerced_type = regex_coercion(&left_type,
&right_type).ok_or_else(|| {
+ plan_datafusion_err!(
+ "There isn't a common type to coerce {left_type} and
{right_type} in SIMILAR TO expression"
+ )
+ })?;
+ let expr = match left_type {
+ DataType::Dictionary(_, inner) if *inner == DataType::Utf8
=> expr,
Review Comment:
it seems a bit odd here to limit it only to `Utf8` and not other string types
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]