array length in Athena

0

In Athena I've a column with an array(json), is there a way to calculate the length of that array for every row?

Paola
posta 7 mesi fa1189 visualizzazioni
2 Risposte
1
Risposta accettata

Hi,

You can calculate the length of the array in Athena using the CARDINALITY function [1].
Here's the basic syntax:

SELECT CARDINALITY(json_column_name) AS array_length
FROM your_table_name;

Reference:
[1] https://docs.aws.amazon.com/athena/latest/ug/finding-lengths.html

Thanks,
Atul

profile picture
con risposta 7 mesi fa
profile picture
ESPERTO
verificato 7 mesi fa
profile pictureAWS
ESPERTO
verificato 7 mesi fa
0

It works, thank you!

Paola
con risposta 7 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande