[
https://issues.apache.org/jira/browse/FLINK-41337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ramin Gharib reassigned FLINK-41337:
------------------------------------
Assignee: Ramin Gharib
> Add IS_VARIANT_NULL, VARIANT_TYPE, VARIANT_KEYS and VARIANT_EXISTS
> ------------------------------------------------------------------
>
> Key: FLINK-41337
> URL: https://issues.apache.org/jira/browse/FLINK-41337
> Project: Flink
> Issue Type: Sub-task
> Components: Table SQL / API, Table SQL / Runtime
> Reporter: Ramin Gharib
> Assignee: Ramin Gharib
> Priority: Major
>
> Adds four functions that read a VARIANT without changing it.
> {code:sql}
> IS_VARIANT_NULL(variant) -- BOOLEAN
> VARIANT_TYPE(variant) -- STRING
> VARIANT_KEYS(variant) -- ARRAY<STRING>
> VARIANT_EXISTS(variant, path) -- BOOLEAN
> -- v =
> {"order_id":17,"user":{"name":"ada","email":"[email protected]"},"items":[{"sku":"A1","qty":2}],"coupon":null}
> IS_VARIANT_NULL(v['coupon']) -- TRUE
> VARIANT_TYPE(v['items']) -- 'ARRAY'
> VARIANT_KEYS(v['user']) -- ['email', 'name']
> VARIANT_EXISTS(v, '$.coupon') -- TRUE
> {code}
> Scope:
> * IS_VARIANT_NULL is TRUE only for a variant null. SQL NULL gives NULL, as
> the FLIP decides in its open question.
> * VARIANT_TYPE returns the Variant.Type name of the top-level value and keeps
> the stored size, so a 1 in 1 byte gives TINYINT. It reads only the header.
> * VARIANT_KEYS returns the field names of an object, sorted by name. An
> array, a scalar or a variant null gives NULL.
> * VARIANT_EXISTS is TRUE for any value at the path, even a variant null. A
> missing key, an index past the end or a path through a scalar gives FALSE.
> * VARIANT_EXISTS parses the path with SimplePath and reuses
> VariantGetFunction.navigate, moved to a shared helper. A malformed constant
> path fails at planning.
> * Table API and PyFlink expressions, SQL and Table API tests, docs.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)