Commit ce12d6c
authored
Add rand() alias for random() (#22147)
## Which issue does this PR close?
- Closes #.
## Rationale for this change
`rand()` is a common alias for `random()` in SQL engines. Supporting it
improves compatibility and lets users write `rand()` as an equivalent
zero-argument volatile random function.
## What changes are included in this PR?
- Adds `rand` as an alias for the existing `random()` scalar function.
- Adds a sqllogictest case verifying that `rand()` resolves successfully
and returns a `Float64` value in the expected `[0, 1)` range.
## Are these changes tested?
Yes.
- `cargo fmt --all`
- `cargo test --package datafusion-functions random --lib`
- `cargo test --features backtrace,parquet_encryption --profile ci
--package datafusion-sqllogictest --test sqllogictests -- functions.slt`
## Are there any user-facing changes?
Yes. Users can now call `rand()` as an alias for `random()`.1 parent cf57f3e commit ce12d6c
3 files changed
Lines changed: 21 additions & 0 deletions
File tree
- datafusion
- functions/src/math
- sqllogictest/test_files
- docs/source/user-guide/sql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
841 | 841 | | |
842 | 842 | | |
843 | 843 | | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
844 | 850 | | |
845 | 851 | | |
846 | 852 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
739 | 740 | | |
740 | 741 | | |
741 | 742 | | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
742 | 747 | | |
743 | 748 | | |
744 | 749 | | |
| |||
759 | 764 | | |
760 | 765 | | |
761 | 766 | | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
762 | 771 | | |
763 | 772 | | |
764 | 773 | | |
| |||
0 commit comments