[ 
https://issues.apache.org/jira/browse/FLINK-39049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18093881#comment-18093881
 ] 

Jinkun Liu commented on FLINK-39049:
------------------------------------

Hello [~dylanhz] [~yunfengzhou] [~sxnan].

Could someone please check whether there are any design issues with this and 
assign it to me? Thanks a lot!

> Introduce built-in functions `VARIANT_GET` and `TRY_VARIANT_GET ` 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