[ 
https://issues.apache.org/jira/browse/FLINK-39049?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jinkun Liu updated FLINK-39049:
-------------------------------
    Summary: Introduce built-in functions `VARIANT_GET` and `VARIANT_QUERY` to 
extract values from a variant  (was: Introduce built-in functions 
`VARIANT_VALUE` and `VARIANT_QUERY` to extract values from a variant)

> Introduce built-in functions `VARIANT_GET` and `VARIANT_QUERY` to extract 
> values from a variant
> -----------------------------------------------------------------------------------------------
>
>                 Key: FLINK-39049
>                 URL: https://issues.apache.org/jira/browse/FLINK-39049
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / API
>            Reporter: Jinkun Liu
>            Priority: Major
>
> ||SQL Function||Table Function||Description||
> |VARIANT_GET(variant, path RETURNING)|VARIANT.variantGet(variant, path, 
> returnType])|Extracts a sub-value from a Variant using the specified path and 
> casts it to the target type. 
>  
> If the path does not exist or is invalid, this function returns {{{}NULL{}}}. 
> If the target return type is incompatible with the extracted value, this 
> function throws an error. 
>  
> {{```sql}}
> {{--TRUE}}
> {{VARIANT_GET(PARSE_JSON('\{"a": true}'), '$.a' RETURNING BOOLEAN)}}
>  
> {{-- NULL }}
> {{VARIANT_GET(PARSE_JSON('\{"a": true}'), '$.b' RETURNING INT)}}
>  
> {{-- throws: cannot cast VARIANT(STRING) to INT}}
> {{VARIANT_GET(PARSE_JSON('\{"a": "oops"}'), '$.a' RETURNING INT)}}
> {{```}}|
> |TRY_VARIANT_GET(variant, path RETURNING)|VARIANT.tryVariantGet(variant, 
> path, returnType])|Similar to {{{}VARIANT_GET{}}}, but returns {{NULL}} 
> instead of throwing an error when the extracted value cannot be cast to the 
> target return type. 
>  
> If the path does not exist or is invalid, this function also returns 
> {{{}NULL{}}}.|



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to