rich7420 opened a new pull request, #417:
URL: https://github.com/apache/datafusion-spark/pull/417

   ## Which issue does this PR close?
   
   - Closes #44.
   
   ## Rationale for this change
   
   Spark's `DataFrame.na.drop` filters rows with the internal 
`AtLeastNNonNulls` predicate. Comet added native support in 
apache/datafusion-comet#6180, and having it here lets other engines reuse it. 
This replaces apache/datafusion#27078, which was opened before the crate moved.
   
   ## What changes are included in this PR?
   
   `SparkAtLeastNNonNullsExpr`, a `PhysicalExpr` that callers build directly 
from a threshold and already-planned children, like 
`SparkFromUtcTimestampExpr`. It returns a non-null Boolean, doesn't count NULL 
or NaN values, and skips a row's remaining computed children once the row 
reaches the threshold. It isn't a UDF because a UDF gets its arguments already 
evaluated, so it couldn't skip them.
   
   Also adds a Criterion benchmark.
   
   Two fixes compared with apache/datafusion#27078:
   
   - The bitmap paths for `n = 1` and `n` = number of children repeated a 
scalar child for every row, so a large string literal could overflow the `i32` 
offsets and panic. Scalars are now checked once.
   - A NaN behind nested dictionaries, which `get_field` on a 
dictionary-encoded struct can produce, is no longer counted.
   
   ## Are these changes tested?
   
   The predicate has no SQL function name, so the `.slt` tests and the PySpark 
runner can't call it. The unit tests and the doctest in 
`at_least_n_non_nulls.rs` cover NULL/NaN counting, complex values, dictionary 
and scalar inputs, child skipping, empty batches, and counts on both sides of 
64-row word boundaries. The tests for the two fixes fail without them.
   
   I checked the mixed-type, dictionary/scalar and word-boundary cases with 
`df.na.drop(thresh=n, subset=...)` in PySpark 3.5.8 and 4.2.0, and the results 
matched. Child skipping I only checked against the Spark source: 
`AtLeastNNonNulls.eval` stops after `n` qualifying values.
   
   ## Are there any user-facing changes?
   
   A new public Rust `PhysicalExpr`. There is no SQL function, since Spark 
doesn't have one.
   


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

Reply via email to