kazdy commented on code in PR #170:
URL: https://github.com/apache/hudi-rs/pull/170#discussion_r1800026201


##########
crates/core/src/table/partition.rs:
##########
@@ -506,4 +525,75 @@ mod tests {
 
         assert!(pruner.parse_segments("invalid/path").is_err());
     }
+
+    #[test]
+    fn test_strip_single_quote_for_date_filter() {
+        for data_type in [DataType::Date32, DataType::Date64] {
+            let schema = Schema::new(vec![Field::new("date", 
data_type.clone(), false)]);
+
+            let cast_options = CastOptions {
+                safe: false,
+                format_options: Default::default(),
+            };
+
+            let value = StringArray::from(vec!["2023-01-01"]);
+            let value = cast_with_options(&value, &data_type, 
&cast_options).unwrap();
+
+            let filter_str = "date = '2023-01-01'";
+            let filter = PartitionFilter::try_from((filter_str, &schema));
+            assert!(filter.is_ok());
+            let filter = filter.unwrap();
+            assert_eq!(filter.field.name(), "date");
+            assert_eq!(filter.operator, Operator::Eq);
+            assert_eq!(filter.value.get().0.len(), 1);
+            assert_eq!(filter.value.get().0, value.get().0);
+        }
+    }
+
+    #[test]
+    fn test_strip_single_quote_for_string_filter() {
+        for data_type in [DataType::Utf8, DataType::Utf8View, 
DataType::LargeUtf8] {
+            let schema = Schema::new(vec![Field::new("category", 
data_type.clone(), false)]);
+
+            let cast_options = CastOptions {
+                safe: false,
+                format_options: Default::default(),
+            };
+
+            let value = StringArray::from(vec!["foo"]);
+            let value = cast_with_options(&value, &data_type, 
&cast_options).unwrap();
+
+            let filter_str = "category!='foo'";
+            let filter = PartitionFilter::try_from((filter_str, &schema));
+            assert!(filter.is_ok());
+            let filter = filter.unwrap();
+            assert_eq!(filter.field.name(), "category");
+            assert_eq!(filter.operator, Operator::Ne);
+            assert_eq!(filter.value.get().0.len(), 1);
+            assert_eq!(filter.value.get().0, value.get().0)
+        }
+    }
+
+    #[test]
+    fn test_do_not_strip_one_side_single_quoted_value_for_filter() {
+        let data_type = DataType::Utf8;
+        let schema = Schema::new(vec![Field::new("category", 
data_type.clone(), false)]);
+
+        let cast_options = CastOptions {
+            safe: false,
+            format_options: Default::default(),
+        };
+
+        let value = StringArray::from(vec!["'foo"]);

Review Comment:
   i'm not sure about this, shouldn't this be the responsibility of a query 
engine to parse this?
   The partition pruner could be implemented specifically for a query engine 
first?



-- 
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]

Reply via email to