Apache DataFusion SQL Query Engine
Add tests that random() and uuid() produce unique values for each row in a table (#10248)
Andrew Lamb6f0c693bd37c
diff --git a/datafusion/sqllogictest/test_files/functions.slt b/datafusion/sqllogictest/test_files/functions.sltindex d0d2bac59e..c8675a5d9c 100644--- a/datafusion/sqllogictest/test_files/functions.slt+++ b/datafusion/sqllogictest/test_files/functions.slt@@ -1115,3 +1115,47 @@ query BSELECT 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+