[ 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; SELECT (array[1,2,3])::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 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} > 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; > SELECT (array[1,2,3])::text; > {code} -- This message was sent by Atlassian Jira (v8.3.2#803003)