函数计算对象中元素的数量
是否有一个函数来计算对象
数据类型中的元素数量? array
具有array_size()
。 varchar
具有len()
或length()
。
我已经习惯了其他查询语言,在那里我可以使用size()
或cardination()
之类的函数。
Is there a function for counting the number of elements in an OBJECT
data type? ARRAY
has ARRAY_SIZE()
. VARCHAR
has LEN()
or LENGTH()
.
I am used to other query languages where I can use a function like SIZE()
or CARDINALITY()
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以想到使用Snowflake SQL进行
array_size(object_keys(x))
的最佳答案。但是,这似乎比需要的要复杂。对于检查空的
对象
(基数0)的特殊情况,我可以比较x = object_construct()
。The best answer I can think of using Snowflake SQL to do
ARRAY_SIZE(OBJECT_KEYS(x))
. However, this seems more complicated than it needs to be.For the special case of checking for empty
OBJECT
(cardinality 0), I could comparex = OBJECT_CONSTRUCT()
.