I have a column full of arrays containing split http requests. I have them filtered down to one of two possibilities:
|[, courses, 27381...|
|[, courses, 27547...|
|[, api, v1, cours...|
|[, api, v1, cours...|
|[, api, v1, cours...|
|[, api, v1, cours...|
|[, api, v1, cours...|
|[, api, v1, cours...|
|[, api, v1, cours...|
|[, api, v1, cours...|
|[, courses, 33287...|
|[, courses, 24024...|
In both array-types, from 'courses' onward is the same data and structure.
I want to take the slice of the array using a case
statement where if the first element of the array is 'api', then take elements 3 -> end of the array. I've tried using Python slice syntax [3:]
, and normal PostgreSQL
syntax [3, n]
where n
is the length of the array. If it's not 'api', then just take the given value.
My ideal end-result would be an array where every row shares the same structure, with courses in the first index for easier parsing from that point onwards.