You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "benj (Jira)" <ji...@apache.org> on 2019/09/16 07:45:00 UTC

[jira] [Updated] (DRILL-7375) composite type map cast/convert_to

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

benj updated DRILL-7375:
------------------------
    Description: 
As it possible to cast varchar to map (JSON) with convert_from
{code:sql}
SELECT a, typeof(a) from (SELECT CONVERT_FROM('{a : 100, b: 200}' ,'JSON') a);
+-------------------+--------+
|         a         | EXPR$1 |
+-------------------+--------+
| {"a":100,"b":200} | MAP    |
+-------------------+--------+
{code}
It will be very usefull to have the capacity to "cast" the _MAP_ into VARCHAR with a "cast syntax" or with a "convert_to" possibility
 Expected:
{code:sql}
SELECT a, typeof(a) ta, va, typeof(va) tva FROM (
SELECT a, CAST(a AS varchar) va from (SELECT CONVERT_FROM('{a : 100, b: 200}' ,'JSON') a));
+-------------------+------+-------------------+---------+
|         a         | ta   | va                | tva     |
+-------------------+------+-------------------+---------+
| {"a":100,"b":200} | MAP  | {"a":100,"b":200} | VARCHAR |
+-------------------+------+-------------------+---------+
{code}
Please note that these possibility of course exists in other database systems
 Example with postgres:
{code:sql}
SELECT '{"a":100,"b":200}'::json::text
{code}

  was:
As it possible to cast varchar to map (JSON) with convert_from
{code:sql}
SELECT a, typeof(a) from (SELECT CONVERT_FROM('{a : 100, b: 200}' ,'JSON') a);
+-------------------+--------+
|         a         | EXPR$1 |
+-------------------+--------+
| {"a":100,"b":200} | MAP    |
+-------------------+--------+
{code}

It will be very usefull to have the capacity to "cast" the _MAP_ into VARCHAR with a "cast syntax" or with a "convert_to" possibility

Please note that these possibility of course exists in other database systems (example postgres : _SELECT '{"a":100,"b":200}'::json::text_)


> composite type map cast/convert_to
> ----------------------------------
>
>                 Key: DRILL-7375
>                 URL: https://issues.apache.org/jira/browse/DRILL-7375
>             Project: Apache Drill
>          Issue Type: Wish
>          Components: Functions - Drill
>    Affects Versions: 1.16.0
>            Reporter: benj
>            Priority: Major
>
> As it possible to cast varchar to map (JSON) with convert_from
> {code:sql}
> SELECT a, typeof(a) from (SELECT CONVERT_FROM('{a : 100, b: 200}' ,'JSON') a);
> +-------------------+--------+
> |         a         | EXPR$1 |
> +-------------------+--------+
> | {"a":100,"b":200} | MAP    |
> +-------------------+--------+
> {code}
> It will be very usefull to have the capacity to "cast" the _MAP_ into VARCHAR with a "cast syntax" or with a "convert_to" possibility
>  Expected:
> {code:sql}
> SELECT a, typeof(a) ta, va, typeof(va) tva FROM (
> SELECT a, CAST(a AS varchar) va from (SELECT CONVERT_FROM('{a : 100, b: 200}' ,'JSON') a));
> +-------------------+------+-------------------+---------+
> |         a         | ta   | va                | tva     |
> +-------------------+------+-------------------+---------+
> | {"a":100,"b":200} | MAP  | {"a":100,"b":200} | VARCHAR |
> +-------------------+------+-------------------+---------+
> {code}
> Please note that these possibility of course exists in other database systems
>  Example with postgres:
> {code:sql}
> SELECT '{"a":100,"b":200}'::json::text
> {code}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)