nevi-me commented on a change in pull request #508:
URL: https://github.com/apache/arrow-datafusion/pull/508#discussion_r646248751
##########
File path: datafusion/src/physical_optimizer/pruning.rs
##########
@@ -1095,6 +1133,60 @@ mod tests {
Ok(())
}
+ #[test]
+ fn row_group_predicate_starts_with() -> Result<()> {
+ let schema = Schema::new(vec![Field::new("c1", DataType::Utf8, true)]);
+ // test LIKE operator that is converted to a 'starts_with'
+ let expr = col("c1").like(lit("Banana%"));
+ let expected_expr =
+ "#c1_min LtEq Utf8(\"Banana\") And Utf8(\"Banana\") LtEq #c1_max";
+ let predicate_expr =
+ build_predicate_expression(&expr, &schema, &mut
RequiredStatColumns::new())?;
+ assert_eq!(format!("{:?}", predicate_expr), expected_expr);
+
+ Ok(())
+ }
+
+ #[test]
+ fn row_group_predicate_like() -> Result<()> {
+ let schema = Schema::new(vec![Field::new("c1", DataType::Utf8, true)]);
+ // test LIKE operator that can't be converted to a 'starts_with'
+ let expr = col("c1").like(lit("%Banana%"));
+ let expected_expr = "Boolean(true)";
+ let predicate_expr =
+ build_predicate_expression(&expr, &schema, &mut
RequiredStatColumns::new())?;
+ assert_eq!(format!("{:?}", predicate_expr), expected_expr);
+
+ Ok(())
+ }
+
+ #[test]
+ fn row_group_predicate_not_starts_with() -> Result<()> {
+ let schema = Schema::new(vec![Field::new("c1", DataType::Utf8, true)]);
+ // test LIKE operator that can't be converted to a 'starts_with'
+ let expr = col("c1").not().like(lit("Banana%"));
Review comment:
This explains why the filter was negated, thanks!
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]