apache / apache/datafusion

support seed for random function

Open
#17,686 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

for example,
in https://github.com/lakehq/sail/blob/main/crates/sail-plan/src/extension/function/math/randn.rs

it seems that every record batch will have same init seed and same random result.

### Describe the solution you'd like

add partition & record_batch_index into evalutate method arguments.

e.g.

```rust
pub trait PhysicalExpr {
fn evaluate(&self, batch: &RecordBatch, partiton: usize, record_batch_index: usize) -> Result;
}
```

then we get different seed for different record batch.

in spark, seeds are different for different partitions.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with crates/sail-plan/src/extension/function/math/randn.rs and inspect the PhysicalExpr::evaluate signature proposed in the issue. Trace how partition and record-batch context would reach evaluation before choosing an approach. Done means random seeds or results can differ across partitions and record batches, with the relevant behavior verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-engineering
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.