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 tests that random() and uuid() produce unique values for each row #10248

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions datafusion/sqllogictest/test_files/functions.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1115,3 +1115,47 @@ query B
SELECT r FROM (SELECT r1 == r2 r, r1, r2 FROM (SELECT random()+1 r1, random()+1 r2) WHERE r1 > 0 AND r2 > 0)
----
false

#######
# verify that random() returns a different value for each row
#######
statement ok
create table t as values (1), (2);

statement ok
create table rand_table as select random() as r from t;

# should have 2 distinct values (not 1)
query I
select count(distinct r) from rand_table;
----
2

statement ok
drop table rand_table

statement ok
drop table t


#######
# verify that uuid() returns a different value for each row
#######
statement ok
create table t as values (1), (2);

statement ok
create table uuid_table as select uuid() as u from t;

# should have 2 distinct values (not 1)
query I
select count(distinct u) from uuid_table;
----
2

statement ok
drop table uuid_table

statement ok
drop table t