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
asked 6 months ago1027 views
2 Answers
1
Accepted Answer

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
answered 6 months ago
profile picture
EXPERT
reviewed 6 months ago
profile pictureAWS
EXPERT
reviewed 6 months ago
0

It works, thank you!

Paola
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions