dtenedor opened a new pull request, #48004:
URL: https://github.com/apache/spark/pull/48004

   ### What changes were proposed in this pull request?
   
   This PR introduces two new SQL functions "randstr" and "uniform" to generate 
random strings or numbers within ranges.
   
   * The "randstr" function returns a string of the specified length whose 
characters are chosen uniformly at random from the following pool of 
characters: 0-9, a-z, A-Z. The random seed is optional. The string length must 
be a constant two-byte or four-byte integer (SMALLINT or INT, respectively).
   * The "uniform" function returns a random value with independent and 
identically distributed  values with the specified range of numbers. The random 
seed is optional. The provided numbers specifying the minimum and maximum 
values of the range must be constant. If both of these numbers are integers, 
then the result will also be an integer. Otherwise if one or both of these are 
floating-point numbers, then the result will also be a floating-point number.
   
   For example:
   
   ```
   SELECT randstr(5);
   > 8i70B
   
   SELECT randstr(10, 0) FROM VALUES (0), (1), (2) tab(col);
   > 2iAhij5i3F
     3AD1fIHj7B
     8i70BBEJ6A
   
   SELECT uniform(10, 20.0F);
   > 17.604954
   
   SELECT uniform(10, 20, 0) FROM VALUES (0), (1), (2) tab(col);
   > 15
     16
     17
   ```
   
   ### Why are the changes needed?
   
   This improves the SQL functionality of Apache Spark and improves its parity 
with other systems.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, see above.
   
   ### How was this patch tested?
   
   This PR adds golden file based test coverage.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Not this time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to