Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secure_random() and secure_random(lower,upper) Presto functions #6085

Closed

Conversation

arundpanicker
Copy link
Contributor

Add secure_random() and secure_random(lower,upper) Presto functions using the secure random functions available in the folly library. Alias secure_rand(), secure_rand(lower, upper).

Resolves : #5762 , prestodb/presto#20530

Reference : https://github.com/prestodb/presto/blob/8a9e1b6feae2d6caea3d2723c5d6a129448052bb/presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java#L704

https://github.com/facebook/folly/blob/e9e2c3f5ae87aa02b3740c935296efddecefd18f/folly/Random.h

@netlify
Copy link

netlify bot commented Aug 11, 2023

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 6da0ad9
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6506a8593c125f0009e007d0

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 11, 2023
@arundpanicker arundpanicker force-pushed the secure_random branch 2 times, most recently from a8520ff to 98aa9e8 Compare August 22, 2023 04:10
@aditi-pandit aditi-pandit changed the title Implementation of secure_random() and secure_random(lower,upper) functions Add secure_random() and secure_random(lower,upper) Presto functions Aug 24, 2023
Returns a cryptographically secure random value in the range 0.0 <= x < 1.0.

.. function:: secure_random(lower, upper) → [same as input]
:noindex:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove :noindex:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

velox/functions/prestosql/Rand.h Outdated Show resolved Hide resolved
velox/functions/prestosql/tests/RandTest.cpp Outdated Show resolved Hide resolved
@ethanyzhang
Copy link

@aditi-pandit Can you take another look at this PR?

@aditi-pandit
Copy link
Collaborator


FOLLY_ALWAYS_INLINE void
call(double& out, const double lower, const double upper) {
VELOX_USER_CHECK_GT(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe have an common inline function (with template type for lower and upper) with just this check statement so that its not repeated in all the functions.

@@ -74,5 +74,124 @@ TEST_F(RandTest, nonNullInt8) {
EXPECT_LT(rand(4), 4);
}

class SecureRandTest : public functions::test::FunctionBaseTest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There isn't a need to make a separate SecureRandTest class for a single secureRand function. You can add secureRand function in RandTest itself.

}

TEST_F(SecureRandTest, int64Args) {
auto result =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add test cases with kInf, kNan, numeric_limits::max(), numeric_limits::min() and null values for all the functions.

Copy link

stale bot commented Mar 15, 2024

This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the PR, make sure you've addressed reviewer comments, and rebase on the latest main. Thank you for your contributions!

@stale stale bot added the stale label Mar 15, 2024
@wills-feng
Copy link
Contributor

@aditi-pandit I'm handling this one in #9295
We can close this one.

Copy link

stale bot commented Jun 27, 2024

This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the PR, make sure you've addressed reviewer comments, and rebase on the latest main. Thank you for your contributions!

@stale stale bot added the stale label Jun 27, 2024
@stale stale bot closed this Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement secure_rand in prestosql
5 participants