Skip to content

Commit

Permalink
Add tests that random() and uuid() produce unique values for each row…
Browse files Browse the repository at this point in the history
… in a table (apache#10248)
  • Loading branch information
alamb committed Apr 26, 2024
1 parent c22c299 commit 6f0c693
Showing 1 changed file with 44 additions and 0 deletions.
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

0 comments on commit 6f0c693

Please sign in to comment.