This is an automated email from the ASF dual-hosted git repository.
jayzhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 6f0c693bd3 Add tests that random() and uuid() produce unique values
for each row in a table (#10248)
6f0c693bd3 is described below
commit 6f0c693bd37cf9f1bb44dabc597551e0102efb34
Author: Andrew Lamb <[email protected]>
AuthorDate: Fri Apr 26 08:36:05 2024 -0400
Add tests that random() and uuid() produce unique values for each row in a
table (#10248)
---
datafusion/sqllogictest/test_files/functions.slt | 44 ++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/datafusion/sqllogictest/test_files/functions.slt
b/datafusion/sqllogictest/test_files/functions.slt
index d0d2bac59e..c8675a5d9c 100644
--- a/datafusion/sqllogictest/test_files/functions.slt
+++ b/datafusion/sqllogictest/test_files/functions.slt
@@ -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
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]