You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Nagato-Yuzuru (via GitHub)" <gi...@apache.org> on 2026/10/15 18:53:45 UTC

[PR] Fuzz window nulls [datafusion]

Nagato-Yuzuru opened a new pull request, #26386:
URL: https://github.com/apache/datafusion/pull/26386

   
   <!--
   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.
   -->
   
   Part of #24243. 
   
   This PR adds NULL values to the window fuzz test, as planned.
   
   
   ## 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.  
   
   Please explain the problem you are trying to solve in terms of the user-visible
   behavior, rather than the implementation.
   
   For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of the
   implementation. "COUNT(DISTINCT) returns wrong results when the column contains
   nulls" is the user-visible problem.
   -->
   
   
   The window fuzz test had two gaps:
   
   - The test data had no NULL values.
   - The test used only one sort order: `ASC NULLS FIRST`.
   
   With these gaps closed, the test finds wrong results on `main`. All of them
   come from one known error: #25859.
   
   ## 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.
   -->
   
   - Add NULL values to the test data. The NULL rate changes between 0, 0.01, 0.1
     and 0.5.
   - Give each sort column a random sort direction and a random NULL position.
   
   Note: a seed now gives different data than before this PR.
   
   
   ## What is the testing strategy for this PR?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   Briefly describe how this PR is tested, and point to the specific tests you added. For example: 'This new feature is covered by the `sqllogictest` cases added in `foo.slt`'.
   
   If this PR does not add tests, explain why. For example, if the change is already covered by existing tests, please mention it.
   
   You should also check the `codecov` bot reply on this PR to confirm the changed code is exercised.
   -->
   
   ```bash
   cargo test --profile ci -p datafusion --features extended_tests --test fuzz -- window_fuzz
   ```
   
   On `main`, the test fails. For example:
   
   ```
   WindowFrame { units: Range, start_bound: Preceding(Int32(6)), end_bound: Preceding(Int32(5)), .. },
   window_fn: max(x), random_seed: 267, null_pct: 0.5, pb_cols: ["a"], ..
   ```
   
   All failures have a `RANGE` frame that ends in `N PRECEDING`, and NULL values in
   the data. They occur with all four sort orders (ASC/DESC, NULLS FIRST/LAST).
   
   ## Additional notes
   
   #25860 fixes #25859. With #25860, this test passes. This PR must merge after
   #25860. Or, if the author of #25860 agrees, these commits can go into #25860.
   
   
   ## 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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: add NULL values to Fuzz window [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #26386:
URL: https://github.com/apache/datafusion/pull/26386#issuecomment-6276260591

   Thank you @Nagato-Yuzuru and @jayzhan211 


-- 
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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: add NULL values to Fuzz window [datafusion]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #26386:
URL: https://github.com/apache/datafusion/pull/26386#issuecomment-6201939284

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/26386?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 82.85%. Comparing base ([`b645de0`](https://app.codecov.io/gh/apache/datafusion/commit/b645de03f3d8b48e413b6ca38c4a9a4f48acdd6a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`38e3d8a`](https://app.codecov.io/gh/apache/datafusion/commit/38e3d8ac59a9e28d15cd097a1807cf4c26cbe021?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##             main   #26386      +/-   ##
   ==========================================
   - Coverage   82.85%   82.85%   -0.01%     
   ==========================================
     Files        1151     1151              
     Lines      456012   456012              
     Branches   456012   456012              
   ==========================================
   - Hits       377824   377813      -11     
   - Misses      55235    55243       +8     
   - Partials    22953    22956       +3     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/26386?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: add NULL values to Fuzz window [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #26386:
URL: https://github.com/apache/datafusion/pull/26386


-- 
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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: add NULL values to Fuzz window [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #26386:
URL: https://github.com/apache/datafusion/pull/26386#discussion_r4306428009


##########
datafusion/core/tests/fuzz_cases/window_fuzz.rs:
##########
@@ -759,40 +780,65 @@ fn generate_random_string(rng: &mut StdRng, length: usize) -> String {
 /// Return randomly sized record batches with:
 /// three sorted int32 columns 'a', 'b', 'c' ranged from 0..DISTINCT as columns
 /// one random int32 column x
+///
+/// `sort_options` sets the sort order of 'a', 'b' and 'c', in this sequence.
+/// Each value in 'a', 'b', 'c' and 'x' is NULL with the probability `null_pct`.
 pub(crate) fn make_staggered_batches<const STREAM: bool>(
     len: usize,
     n_distinct: usize,
+    null_pct: f64,
+    sort_options: [SortOptions; 3],
     random_seed: u64,
 ) -> Vec<RecordBatch> {
     // use a random number generator to pick a random sized output
     let mut rng = StdRng::seed_from_u64(random_seed);
-    let mut input123: Vec<(i32, i32, i32)> = vec![(0, 0, 0); len];
-    let mut input4: Vec<i32> = vec![0; len];
+    let mut input123: Vec<(Option<i32>, Option<i32>, Option<i32>)> =

Review Comment:
   nit: now that the keys are ordered with `lexsort_to_indices`, the `input123` tuple vector isn't needed any more. The three key arrays can be built directly:
   
   ```diff
   -    let mut input123: Vec<(Option<i32>, Option<i32>, Option<i32>)> =
   -        vec![(None, None, None); len];
   @@
   -    for v in &mut input123 {
   -        *v = (
   -            random_key(&mut rng),
   -            random_key(&mut rng),
   -            random_key(&mut rng),
   -        )
   -    }
   +    let keys: [ArrayRef; 3] = std::array::from_fn(|_| {
   +        Arc::new(Int32Array::from_iter((0..len).map(|_| random_key(&mut rng)))) as _
   +    });
   @@
   -    let keys: [ArrayRef; 3] = [
   -        Arc::new(Int32Array::from_iter(input123.iter().map(|k| k.0))),
   -        Arc::new(Int32Array::from_iter(input123.iter().map(|k| k.1))),
   -        Arc::new(Int32Array::from_iter(input123.iter().map(|k| k.2))),
   -    ];
   ```



-- 
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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org