I'm querying a column with a variable length JSON array.
select col.pages[1].name, col.pages[2].name from assoc
I get this error when there is only one value in the array.
INVALID_FUNCTION_ARGUMENT: Array subscript out of bounds
How do I prevent this error if there's only one value?
Athena is based on Presto 0.172. You can wrap your expression in Presto's try:
SELECT try(some_array[2]) FROM ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With