erro in cast array
reli
Vertica Customer ✭
Best Answers
-
mosheg
Vertica Employee Administrator
I've tried the following syntax on Vertica 10.x and it works.
SELECT STRING_TO_ARRAY('[95.717,95.718,95.717,95.717,95.717]', ','); STRING_TO_ARRAY ------------------------------------------------ ["95.717","95.718","95.717","95.717","95.717"] (1 row) SELECT STRING_TO_ARRAY('[95.717,95.718,95.717,95.717,95.717]', ',')::ARRAY[FLOAT]; STRING_TO_ARRAY -------------------------------------- [95.717,95.718,95.717,95.717,95.717] (1 row)Does it answer your need?
1

Answers
I have v9.3.1-7 maybe this is the reason. Thank you!
This is a nice discovery, Vertica writes arrays as JSON strings, and STRING_TO_ARRAY can parse JSON strings into arrays:
SELECT STRING_TO_ARRAY('1,2,3,5,8,13,21,34'); / => ["1","2","3","5","8","13","21","34"] SELECT STRING_TO_ARRAY('1,2,3,5,8,13,21,34') = '["1","2","3","5","8","13","21","34"]'; // => true SELECT STRING_TO_ARRAY('["1","2","3","5","8","13","21","34"]')= '["1","2","3","5","8","13","21","34"]';// => true SELECT STRING_TO_ARRAY('["1","2","3","5","8","13","21","34"]')= ARRAY[1,2,3,5,8,13,21,34]; // => true