Skip to content

Add rand() alias for random()#22147

Open
xiedeyantu wants to merge 2 commits into
apache:mainfrom
xiedeyantu:rand
Open

Add rand() alias for random()#22147
xiedeyantu wants to merge 2 commits into
apache:mainfrom
xiedeyantu:rand

Conversation

@xiedeyantu
Copy link
Copy Markdown
Member

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().

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels May 13, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 13, 2026
Copy link
Copy Markdown
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiedeyantu
Thanks for working on this.

Looks 👍 to me

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

Labels

documentation Improvements or additions to documentation functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants