File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
ql/src/test/org/apache/hadoop/hive/ql/udf Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 28
28
import static org .junit .Assert .assertNotEquals ;
29
29
import org .junit .Test ;
30
30
31
+ import java .util .UUID ;
31
32
import java .util .concurrent .TimeUnit ;
32
33
33
34
/**
@@ -49,13 +50,18 @@ public void testUUID() throws Exception {
49
50
@ Test
50
51
public void testUUIDv7 () throws Exception {
51
52
UDFUUIDv7 udf = new UDFUUIDv7 ();
53
+ long timestampBefore = System .currentTimeMillis ();
52
54
String id1 = udf .evaluate (null ).toString ();
55
+ long timestampAfter = System .currentTimeMillis ();
56
+ UUID v7id1 = UUID .fromString (id1 );
57
+ assertEquals (7 , v7id1 .version ());;
58
+ long v7IdTimeStamp = v7id1 .getMostSignificantBits () >>> 16 ;
59
+ assertTrue (v7IdTimeStamp <= timestampAfter && timestampBefore <= v7IdTimeStamp );
53
60
String id2 = udf .evaluate (null ).toString ();
54
61
assertNotEquals (id1 , id2 );
55
62
assertEquals (36 , id1 .length ());
56
63
assertEquals (36 , id2 .length ());
57
64
GenericUDFBridge bridge = new GenericUDFBridge ("uuid_v7" , false , UDFUUIDv7 .class .getName ());
58
65
assertFalse (FunctionRegistry .isDeterministic (bridge ));
59
66
}
60
-
61
67
}
You can’t perform that action at this time.
0 commit comments