BsoBird commented on code in PR #5891:
URL: https://github.com/apache/hive/pull/5891#discussion_r2167076060
##########
ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFUUID.java:
##########
@@ -23,26 +23,41 @@
import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import org.junit.Test;
+import java.util.concurrent.TimeUnit;
+
/**
* TestUDFUUID.
*/
public class TestUDFUUID {
@Test
public void testUUID() throws Exception {
UDFUUID udf = new UDFUUID();
-
String id1 = udf.evaluate().toString();
String id2 = udf.evaluate().toString();
-
assertFalse(id1.equals(id2));
-
assertEquals(id1.length(), 36);
assertEquals(id2.length(), 36);
-
GenericUDFBridge bridge = new GenericUDFBridge("uuid", false,
UDFUUID.class.getName());
assertFalse(FunctionRegistry.isDeterministic(bridge));
}
+
+ @Test
+ public void testUUIDv7() throws Exception {
+ UDFUUIDv7 udf = new UDFUUIDv7();
+ String id1 = udf.evaluate(null).toString();
+ TimeUnit.MILLISECONDS.sleep(1);
Review Comment:
@deniskuzZ There is no such thing as asynchronously waiting for the previous
task to complete before executing the next task here. I just want to delay the
time by 1 millisecond before generating the second UUIDV7 and ensure that the
latter UUID is definitely greater than the former one. If this condition is not
met, then the UUID we generated must not comply with the UUIDV7 specification.
```
String v7_uuid_id1 = udf.evaluate(null).toString();
TimeUnit.MILLISECONDS.sleep(1);
String v7_uuid_id2 = udf.evaluate(null).toString();
assertTrue(v7_uuid_id2.compareTo(v7_uuid_id1)>0); //id2 must be greater
than ID1
```
If we don't verify the time-sequential characteristic of UUIDV7 in unit
tests, that seems too strange.
--
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]