Skip to content

Line: skip null and NaN x rows instead of rejecting them #25

Closed

Description

@jvdd

Summary

An ungrouped minmax line on a resident frame rejects an x column that holds nulls or NaN. The scan plan drops null-x rows silently and emits NaN-x rows as points. Histograms skip nulls and NaN on both paths. The line trace can do the same on both paths, and warn once instead of raising.

Why the skip is cheap

The resident check requires x sorted in Polars order. In that order every null is a prefix and every NaN is a suffix, and Series.is_sorted() accepts exactly that layout. So the kernel never needs a filter pass:

  • Nulls: exclude the first null_count() rows from the bucket-edge search, so no window starts before the first valid x.
  • NaN, float x only: key each value as positive infinity in the edge comparison, so the NaN suffix lies past the closed upper bound and never enters a bucket.
  • Scan plan: add one is_not_nan filter for float x. Nulls are already dropped through the null bucket key.
  • The check that already collects x once counts nulls and NaN and warns once per source and column with the counts.

The all-null x case keeps its empty result. A null or NaN in the middle of x stays an error, because the column is not sorted in Polars order.

Tests to add

  • Trailing NaN and leading nulls: resident output equals scan output and holds no null or NaN x.
  • A null prefix that spans more than one chunk at the kernel level.
  • One warning on the first request, none on the second.

Out of scope

Grouped lines keep row-count buckets and the old behavior, see #16.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions