0

I have array field as give below in a column call emailed_user

[[email protected],[email protected],[email protected],[email protected]]

I want to find number of element in the array.

I have written the code for the above ARRAY_LENGTH(SPLIT(emailed_users),",") as Number_of_items2

I am getting error No matching signature for function SPLIT for argument types: ARRAY. Supported signatures: SPLIT(STRING, [STRING]); SPLIT(BYTES, BYTES) Could you please help me. Answer can be given in standardsql I am using Googlesql

1 Answer 1

1

You should use below

ARRAY_LENGTH(emailed_users) as Number_of_items2   

As you can see - you don't need SPLIT because your emailed_users field is already of type ARRAY

Quick test below

#standardSQL
WITH `project.dataset.table` AS (
  SELECT ['[email protected]','[email protected]','[email protected]','[email protected]'] emailed_users
)
SELECT ARRAY_LENGTH(emailed_users) AS Number_of_items2  
FROM `project.dataset.table`   

with result

Row Number_of_items2     
1   4    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.