用bigquery计算数组长度 returns 1 空的时候
Count the length of an array with bigquery returns 1 when empty
我有如下文本字符串:
text_string
"1","4","9","8","12","10","7","13","15","5","14"
然后我需要统计成员的数量。因此,为此我使用了以下函数:
ARRAY_LENGTH(SPLIT(text_string,",")) which returns 11 and it is fine.
但是当text_string
为空时,它总是returns 1.
我该如何解决这个问题?
SPLIT
documentation 说,
Splitting an empty STRING returns an ARRAY with a single empty STRING.
我不太确定,但你不能做类似的事情吗,
IF(text_string = "", 0, ARRAY_LENGTH(SPLIT(text_string,",")))
我有如下文本字符串:
text_string
"1","4","9","8","12","10","7","13","15","5","14"
然后我需要统计成员的数量。因此,为此我使用了以下函数:
ARRAY_LENGTH(SPLIT(text_string,",")) which returns 11 and it is fine.
但是当text_string
为空时,它总是returns 1.
我该如何解决这个问题?
SPLIT
documentation 说,
Splitting an empty STRING returns an ARRAY with a single empty STRING.
我不太确定,但你不能做类似的事情吗,
IF(text_string = "", 0, ARRAY_LENGTH(SPLIT(text_string,",")))