Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime 15.3 and above
Convert a complex expression (ARRAY, MAP, STRUCT) into a VARIANT where maps and structs are converted to variant objects which are unordered. MAP can only have STRING keys.
Syntax
to_variant_object(expr)
Arguments
expr: ASTRUCT,MAP<STRING, ...>, orARRAYexpression.
Returns
A VARIANT.
Examples
> SELECT to_variant_object(named_struct('a', 1, 'b', 2));
{"a":1,"b":2}
> SELECT to_variant_object(array(1, 2, 3));
[1,2,3]
> SELECT to_variant_object(array(named_struct('a', 1)));
[{"a":1}]
> SELECT to_variant_object(array(map("a", 2)));
[{"a":2}]