Can we do a regex search on vertica's ARRAY (complex type) data type?
rajatpaliwal86
Vertica Customer ✭
https://www.vertica.com/docs/10.0.x/HTML/Content/Authoring/SQLReferenceManual/DataTypes/ARRAY.htm
Can we do a regex search on each element or possibly can we cast it to varchar and do regex?
Tagged:
0
Best Answer
-
Jim_Knicely - Select Field - Administrator
This works too...
dbadmin=> SELECT REGEXP_LIKE(c[0], '[0-9]+'), REGEXP_LIKE(c[1], '[0-9]+'), REGEXP_LIKE(c[2], '[0-9]+') FROM a; REGEXP_LIKE | REGEXP_LIKE | REGEXP_LIKE -------------+-------------+------------- f | f | t (1 row)
5
Answers
You can EXPLODE the array and look at each element.
Example:
Or you can look at the entire ARRAY as a string:
@Jim_Knicely Thank you!!