@@ -97,6 +97,42 @@ func TestIsIPv4(t *testing.T) {
9797 trequire .DatumEqual (t , types .NewDatum (0 ), r )
9898}
9999
100+ func TestIsUUID (t * testing.T ) {
101+ t .Parallel ()
102+ ctx := createContext (t )
103+ tests := []struct {
104+ uuid string
105+ expect interface {}
106+ }{
107+ {"6ccd780c-baba-1026-9564-5b8c656024db" , 1 },
108+ {"6CCD780C-BABA-1026-9564-5B8C656024DB" , 1 },
109+ {"6ccd780cbaba102695645b8c656024db" , 1 },
110+ {"{6ccd780c-baba-1026-9564-5b8c656024db}" , 1 },
111+ {"6ccd780c-baba-1026-9564-5b8c6560" , 0 },
112+ {"6CCD780C-BABA-1026-9564-5B8C656024DQ" , 0 },
113+ // This is a bug in google/uuid#60
114+ {"{99a9ad03-5298-11ec-8f5c-00ff90147ac3*" , 1 },
115+ // This is a format google/uuid support, while mysql doesn't
116+ {"urn:uuid:99a9ad03-5298-11ec-8f5c-00ff90147ac3" , 1 },
117+ }
118+
119+ fc := funcs [ast .IsUUID ]
120+ for _ , test := range tests {
121+ uuid := types .NewStringDatum (test .uuid )
122+ f , err := fc .getFunction (ctx , datumsToConstants ([]types.Datum {uuid }))
123+ require .NoError (t , err )
124+ result , err := evalBuiltinFunc (f , chunk.Row {})
125+ require .NoError (t , err )
126+ trequire .DatumEqual (t , types .NewDatum (test .expect ), result )
127+ }
128+
129+ var argNull types.Datum
130+ f , _ := fc .getFunction (ctx , datumsToConstants ([]types.Datum {argNull }))
131+ r , err := evalBuiltinFunc (f , chunk.Row {})
132+ require .NoError (t , err )
133+ require .True (t , r .IsNull ())
134+ }
135+
100136func TestUUID (t * testing.T ) {
101137 t .Parallel ()
102138 ctx := createContext (t )
0 commit comments