You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/05 21:02:45 UTC

[GitHub] [incubator-doris] FreeOnePlus opened a new issue, #9957: [Feature] Similar to support request for str_to_map function in Hive

FreeOnePlus opened a new issue, #9957:
URL: https://github.com/apache/incubator-doris/issues/9957

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Description
   
   Currently in Apache Doris, there is no functionality to support this scenario. I hope the official can support such a function, thank you~
   
   ### Use case
   
   str_to_map(string parameters, delimiter 1, delimiter 2)
   
   Split text into key-value pairs using two delimiters.
   
   Delimiter 1 splits the text into K-V pairs, Delimiter 2 splits each K-V pair. The default delimiter is ',' for delimiter 1 and '=' for delimiter 2.
   
   example:
   1. Create a map field
   `DROP TABLE IF EXISTS tmp.tmp_str_to_map;
   
   CREATE TABLE IF NOT EXISTS tmp.tmp_str_to_map
   
   (
   ocolumn string comment 'original field',
   rcolumn map<string,string> comment 'map field'
   );`
   If the data really wants kv to directly clean the data and convert it into a map:
   
   str_to_map(regexp_replace(params,'[\"|\{|\}]',''),'&',':') as params, --- data is divided by &, kv is divided by:
   
   2. concat + str_to_map function
   Use concat + & to splicing table fields into map type
   `insert overwrite table tmp.tmp_str_to_map
   
   SELECT
   
   concat('&crowd:', m0.id,'&clicker:',m0.dui_leader,'&sen:',m0.application_type) ocolumn,
   
   str_to_map(concat('column1:', m0.id,'&column2:',m0.dui_leader,'&column3:',m0.application_type), '&', ':') rcolumn
   
   FROM tmp.tmp_adhoc_detail_20180927 m0
   
   limit 1
   
   ;`
   3. To use the fields in the map, use [""]
   `select
   
   rcolumn,
   
   rcolumn["column1"] column1
   
   from tmp.tmp_str_to_map;`
   
   4. It can also be directly converted and used without storing fields
   `SELECT
   
     m0.id column1,
   
     str_to_map(concat('column1:', m0.id,'&column2:',m0.dui_leader,'&column3:',m0.application_type), '&', ':')["column1"] column1_1
   
   from tmp.tmp_adhoc_detail_20180927 m0 <br>limit 1
   `
   
   5. Results:
   {"column1":"1","column2":"李某某","column3":"创新班"}
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [I] [Feature] Similar to support request for str_to_map function in Hive [doris]

Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman closed issue #9957: [Feature] Similar to support request for str_to_map function in Hive
URL: https://github.com/apache/doris/issues/9957


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org