I'm trying to lateral flatten a varchar to an array to explode the element within the array
For example [trJGrODW4n4iLRN2A4WeraV740vH4L81ikd7KnRfsD bE578vR4L81isq7YnRchM]
I tried the following:
- I tried to replace the varchar space
with
,"
(doesn't work). - Used
strtok_to_array
--> gets unicode start of string
Select s.value, replace(varchar_col,' ',',"') as to_array_format,
strtok_to_array(varchar_col,'')as strtok_to_array,* from table , lateral flatten(input => strtok_to_array(varchar_col,''))s
Actual result:
1. trJGrODW4n4iLRN2A4WeraV740vH4L81ikd7KnRfsD bE578vR4L81isq7YnRchM
2. [ "trJGrODW4n4iLRN2A4Wer\u0002aV740vH4L81ikd7KnRfsD\u0002bE578vR4L81isq7YnRchM" ]
Expected Result:
1. ["trJGrODW4n4iLRN2A4Wer","aV740vH4L81ikd7KnRfsD","bE578vR4L81isq7YnRchM"]
2. ["trJGrODW4n4iLRN2A4Wer","aV740vH4L81ikd7KnRfsD","bE578vR4L81isq7YnRchM"]