adriangb commented on code in PR #13253: URL: https://github.com/apache/datafusion/pull/13253#discussion_r1828507459
########## datafusion/core/tests/fuzz_cases/pruning.rs: ########## @@ -0,0 +1,188 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use arrow_array::{ArrayRef, BooleanArray, StringArray}; +use arrow_schema::{DataType, Field, Schema}; +use datafusion::physical_optimizer::pruning::{PruningPredicate, PruningStatistics}; +use datafusion::prelude::*; +use datafusion_common::ScalarValue; +use datafusion_expr::{col, lit}; +use datafusion_physical_expr::planner::logical2physical; +use rand::{thread_rng, Rng}; +use std::collections::HashSet; +use std::sync::Arc; + +/// Tests for `LIKE` with truncated statistics to validate incrementing logic +/// +/// Create several 2 row batches and ensure that `LIKE` with the min and max value +/// are correctly pruned even when the "statistics" are trunated. +#[test] +fn test_prune_like_truncated_statistics() { + // Make 2 row random UTF-8 strings + let mut rng = thread_rng(); + let statistics = TestPruningStatistics::new(&mut rng, 100); Review Comment: I imagine a lot of the bugs are going to be around edge cases: empty strings, non-ascii characters, etc. Is there any way we could inject those into the randomness? Maybe what we need here more than random fuzzing is a matrix style test: - Generate N full length values, including some random ones? - Arrange them into row groups in multiple orders, of multiple sizes - Truncate the stats to lengths between 1 and large And make sure the results with and without pruning match? -- 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]
