alamb commented on code in PR #12978: URL: https://github.com/apache/datafusion/pull/12978#discussion_r1920211318
########## datafusion/physical-optimizer/src/pruning.rs: ########## @@ -1605,7 +1627,129 @@ fn build_statistics_expr( Ok(statistics_expr) } +/// Convert `column LIKE literal` where P is a constant prefix of the literal +/// to a range check on the column: `P <= column && column < P'`, where P' is the +/// lowest string after all P* strings. +fn build_like_match( + expr_builder: &mut PruningExpressionBuilder, +) -> Option<Arc<dyn PhysicalExpr>> { + // column LIKE literal => (min, max) LIKE literal split at % => min <= split literal && split literal <= max + // column LIKE 'foo%' => min <= 'foo' && 'foo' <= max + // column LIKE '%foo' => min <= '' && '' <= max => true + // column LIKE '%foo%' => min <= '' && '' <= max => true + // column LIKE 'foo' => min <= 'foo' && 'foo' <= max + + fn unpack_string(s: &ScalarValue) -> Option<&String> { Review Comment: I proposed pulling this function out into its own API here: https://github.com/apache/datafusion/pull/14167 -- 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-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org