[
https://issues.apache.org/jira/browse/IMPALA-15811?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Zoltán Borók-Nagy resolved IMPALA-15811.
----------------------------------------
Fix Version/s: Impala 5.0.0
Resolution: Fixed
> Support DECIMAL(p,s) as a target type of typed variant_get()
> ------------------------------------------------------------
>
> Key: IMPALA-15811
> URL: https://issues.apache.org/jira/browse/IMPALA-15811
> Project: IMPALA
> Issue Type: Sub-task
> Reporter: Zoltán Borók-Nagy
> Assignee: Zoltán Borók-Nagy
> Priority: Major
> Labels: impala-iceberg
> Fix For: Impala 5.0.0
>
>
> The typed form of {{variant_get(v, path, type)}} and {{try_variant_get()}}
> accepts {{boolean}}, {{tinyint}}, {{smallint}}, {{int}}, {{bigint}},
> {{float}}, {{double}}, {{string}} and {{date}} as the target type. A decimal
> type is rejected during analysis:
> {code:sql}
> SELECT variant_get(v, '$.price', 'decimal(10,2)') FROM t;
> -- AnalysisException: variant_get() unsupported target type 'decimal(10,2)'.
> Supported types: boolean, tinyint, smallint, int, bigint, float, double,
> string, date.
> {code}
> VARIANT has decimal physical types (DECIMAL4, DECIMAL8, DECIMAL16), and
> Spark's {{parse_json}} stores a JSON number with a fractional part as a
> decimal. The numeric target types are lossy for such values (IMPALA-15611):
> DOUBLE and FLOAT cannot hold every digit, and the integer types round. The
> only exact way to read them today is through the string form:
> {code:sql}
> SELECT CAST(variant_get(v, '$.price', 'string') AS DECIMAL(10,2)) FROM t;
> {code}
> {{variant_get()}} and {{try_variant_get()}} should accept {{'decimal(p,s)'}}
> as the target type, and convert decimal, integer, floating point and string
> values with the rules of {{CAST(... AS DECIMAL(p,s))}}. Spark's
> {{variant_get}} accepts decimal target types too.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)