Generalize execute_on_ray partitioning (arbitrary key, explicit specs) - #25
Conversation
Test Results1 524 tests +54 1 476 ✅ +54 50s ⏱️ +17s Results for commit 836f22c. ± Comparison against base commit 36d2260. This pull request removes 3 and adds 57 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
5327eb9 to
88e5290
Compare
|
so i THINK that |
25941a3 to
248e147
Compare
You are right, that was a good catch. IT's now deferring materializing things on the driver until actually needed and controlling the number of pending tasks better. |
3bd9619 to
323da24
Compare
…bulary Add io_sources.partitions, a backend-neutral way to describe how to split a read, and route the Ray executor through it. A ReadPartition is one slice of the input, defined by a Polars predicate. A Partitioner derives slices from the predicate pushed down at scan time, with builders for common axes: - by_time: calendar windows, built with Polars' temporal functions - by_value: one slice per discrete value, or per member group - by_range: fixed-width numeric buckets - by_key: equality on caller-enumerated keys - discrete_partitions / cartesian_partitions: explicit member lists and date-window x bucket products execute_on_ray takes a single partitions argument (a partitioner, an explicit list of ReadPartition, or by_key); RayPartition additionally carries per-task remote options. The date_column/time_unit calendar form is retained as a shortcut for by_time. Ordered output streams partitions in spec order by blocking on the next partition while later tasks run ahead, so the number of outstanding results stays bounded by max_concurrency instead of growing with the total output. Signed-off-by: Pascal Tomecek <40371786+ptomecek@users.noreply.github.com>
323da24 to
836f22c
Compare
Description
execute_on_raycurrently partitions only on a single datetime column by calendar unit(
daily/monthly/yearly). This generalizes the distributed source to partition onarbitrary keys and explicit specs, and refactors the calendar path onto a shared execution
core (its public behavior is unchanged). Closes #24.
Two new
LazyFrameentry points on thepiotnamespace:execute_on_ray_by(partitions, by, ...)— partition by equality on caller-enumeratedkeys.
partitionsis a small frame (orSeries/ sequence) with one row per partition;byis a column name, list of names, selector, or apl.Expr(e.g.pl.col("id").hash() % N). Each row runs one Ray task filtered tocol == key.execute_on_ray_partitions(specs, ...)— the general primitive taking an explicit listof
RayPartition(predicate, key, remote_options)specs. Helpersdiscrete_partitions(member lists via
is_in) andcartesian_partitions(date_windows × buckets) buildcommon spec sets.
Changes
LazyFrameacross Ray from a list of partitionpredicates; the calendar
execute_on_rayand both new entry points build specs over it.from results; empty results use the requested output schema.
remote_options— a uniform dict, a struct column, a{key: dict}mapping,or per-
RayPartition.preserve_partition_order=Truerestoresspec order);
execute_on_raykeeps chronological order.return_as/max_concurrencyare validated upfront; outstanding tasks are cancelled when
n_rowsis satisfied or a partition fails.inner.filter(<pushed-down predicate>).filter(<partition predicate>), so a partition predicate reaches inner sources (e.g. a lookback-expandingfilter) unchanged.
execute_on_ray_byskips partitions whose key a pushed-down predicate onthe key column(s) cannot match, evaluated exactly with Polars and restricted to non-float
keys and non-UDF predicates so a matching partition can never be dropped. The explicit
execute_on_ray_partitionsspec list is never pruned.Docs
API-Reference entries for the new functions and a note pointing multi-stage distributed
pipelines at Polars Cloud.
Tests
Partitioning by column and by expression, discrete member lists, compound
date_window × bucket, projection / column retention, empty-result schema, duplicate-keyrejection, completion vs preserved ordering, per-partition options, pruning (including
no-false-prune cases for NaN/
is_in, float coercion,-0.0, casts, UDFs, and multi-columnnulls), and byte-identical single-frame vs distributed results through a lookback source.
test_lazy_ray(38) and the fullpolars_io_toolssuite pass;ruffandmdformatclean.Type of Change
Checklist
make lint-py,make lint-docs)make test-py)