Github user myui commented on the issue:
https://github.com/apache/incubator-hivemall/pull/135
```sql
select
NAMED_STRUCT("Name", "John", "age", 31),
to_json(
NAMED_STRUCT("Name", "John", "age", 31)
),
to_json(
NAMED_STRUCT("Name", "John", "age", 31),
array('Name', 'age')
),
to_json(
NAMED_STRUCT("Name", "John", "age", 31),
array('name', 'age')
),
to_json(
NAMED_STRUCT("Name", "John", "age", 31),
array('age')
),
to_json(
NAMED_STRUCT("Name", "John", "age", 31),
array()
),
to_json(
null,
array()
),
to_json(
struct("123", "456", 789, array(314,007)),
array('ti','si','i','bi')
),
to_json(
struct("123", "456", 789, array(314,007)),
'ti,si,i,bi'
),
to_json(
struct("123", "456", 789, array(314,007))
),
to_json(
NAMED_STRUCT("country", "japan", "city", "tokyo")
),
to_json(
NAMED_STRUCT("country", "japan", "city", "tokyo"),
array('city')
),
to_json(
ARRAY(
NAMED_STRUCT("country", "japan", "city", "tokyo"),
NAMED_STRUCT("country", "japan", "city", "osaka")
)
),
to_json(
ARRAY(
NAMED_STRUCT("country", "japan", "city", "tokyo"),
NAMED_STRUCT("country", "japan", "city", "osaka")
),
array('city')
);
```
> {"name":"John","age":31} {"name":"John","age":31}
{"Name":"John","age":31} {"name":"John","age":31} {"age":31}
{}NULL {"ti":"123","si":"456","i":789,"bi":[314,7]}
{"ti":"123","si":"456","i":789,"bi":[314,7]}
{"col1":"123","col2":"456","col3":789,"col4":[314,7]}
{"country":"japan","city":"tokyo"} {"city":"tokyo"}
[{"country":"japan","city":"tokyo"},{"country":"japan","city":"osaka"}]
[{"country":"japan","city":"tokyo"},{"country":"japan","city":"osaka"}]
```sql
select
from_json(
'{ "person" : { "name" : "makoto" , "age" : 37 } }',
'struct<name:string,age:int>',
array('person')
),
from_json(
'[0.1,1.1,2.2]',
'array<double>'
),
from_json(to_json(
ARRAY(
NAMED_STRUCT("country", "japan", "city", "tokyo"),
NAMED_STRUCT("country", "japan", "city", "osaka")
)
),'array<struct<country:string,city:string>>'),
from_json(to_json(
ARRAY(
NAMED_STRUCT("country", "japan", "city", "tokyo"),
NAMED_STRUCT("country", "japan", "city", "osaka")
),
array('city')
), 'array<struct<country:string,city:string>>'),
from_json(to_json(
ARRAY(
NAMED_STRUCT("country", "japan", "city", "tokyo"),
NAMED_STRUCT("country", "japan", "city", "osaka")
)
),'array<struct<city:string>>');
```
> {"name":"makoto","age":37} [0.1,1.1,2.2]
[{"country":"japan","city":"tokyo"},{"country":"japan","city":"osaka"}]
[{"country":"japan","city":"tokyo"},{"country":"japan","city":"osaka"}]
[{"city":"tokyo"},{"city":"osaka"}]
---