2010YOUY01 opened a new pull request, #15501:
URL: https://github.com/apache/datafusion/pull/15501

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes #.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   Recently we have detected multiple bugs for out-of-core sorting, and there 
are many potential fixes/improvements that will change the sort execution code, 
thus more test coverage is intended.
   
   The existing sort fuzzer 
https://github.com/apache/datafusion/blob/main/datafusion/core/tests/fuzz_cases/sort_fuzz.rs
 only tests on `SortExec` instead of end-to-end sort queries, and it only 
includes int and string types.
   This new fuzzer will run end-to-end sort queries with multiple partiitons, 
and increases the test coverage for more dataset types, include `TopK` 
executors, and test all related configuration options.
   
   The new sort fuzzer is able to detect known bugs in 
https://github.com/apache/datafusion/issues/14748, so the random query 
generation will avoid the known issues (e.g. don't generate utf8 sort key, more 
details can be found in code comment)
   It has also detected several new bugs, for example: 
https://github.com/apache/datafusion/pull/15469 and 
https://github.com/apache/datafusion/pull/15355
   There are other bugs detected and it's not obvious why it fails, so now by 
default, it will only run with unbounded memory limit, perhaps we should retry 
it after the knwon issues like 
https://github.com/apache/datafusion/issues/14748 are cleared. An example of 
other failed query (TODO)
   
   ### Implementation
   There are two key structs in the sort query fuzzer:
   - `SortQueryFuzzer`: controls the runner config like how many rounds to run, 
and how many queries to test inside each round.
   - `SortFuzzerTestGenerator`: Generates random datasets, queries, and configs.
   
   The log looks like
   ```
   [SortQueryFuzzer] Round 0, Query 0 (Config 9)
     Seeds:
       init_seed   = 5007153919587973719
       query_seed  = 4047642740781589262
       config_seed = 13112349042886494469
     Dataset schema:
       [timestamp_ns:Timestamp(Nanosecond, None);N, u32:UInt32;N, 
time32_ms:Time32(Millisecond);N, i16:Int16;N, 
timestamp_ms:Timestamp(Millisecond, None);N, u8_low:UInt8;N]
     Query:
       SELECT * FROM sort_fuzz_table ORDER BY u32 DESC
     Config:
       Dataset size: 93.2 KB
       Number of partitions: 3
       Batch size: 6
       Memory limit: Unbounded
       Per partition memory limit: Unbounded
       Sort spill reservation bytes: 10.3 KB
       Sort in place threshold bytes: 540.0 B
   ```
   There is a utility function to reproduce the failed execution 
deterministically using the above seeds, see the example in (TODO)
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   1. Refactor: move `RecordBatchGenerator` and related structs from 
`datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs` to 
`datafusion/core/tests/fuzz_cases/record_batch_generator.rs`, to reuse the 
dataset generation utilities for aggregation fuzzer to generate dataset with 
more types.
   2. Implement `SortQueryFuzzer` and `SortFuzzerTestGenerator` in 
`sort_query_fuzz.rs`
   
   The entry point is now in `sort_query_fuzz.rs`, and the fuzzer is limited to 
run for up to 20 seconds (around 75 queries on my machine) to keep the overall 
test runtime reasonable. Once the known issues are resolved and the fuzzer runs 
stably without uncovering new bugs, we can move it to the extended test CI job 
and allow it to run for a longer duration.
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   4. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   NA
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   No.
   


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

Reply via email to