티스토리 뷰

공부

[SQL] split & get array index 0

승가비 2020. 3. 14. 02:37
728x90
### Spark SQL
SELECT split('asdf#DDD#1234', '#DDD#')[0]; // asdf;

### Presto
SELECT element_at(split('asdf#DDD#1234', '#DDD#'), 1); //asdf

https://www.tutorialspoint.com/apache_presto/apache_presto_element_at.htm

 

Apache Presto - element_at(array,index) - Tutorialspoint

Apache Presto - element_at(array,index) Advertisements Query 1 presto:default> select array_intersect(array[1,2,3],array[2,4]) as intersection; Result intersection -------------- [2] Query 2 presto:default> select element_at(array[1,2,3],2) as element_posi

www.tutorialspoint.com

https://stackoverflow.com/questions/36200090/how-to-split-a-column

 

How to split a column?

I would like to see if I can split a column in spark dataframes. Like this, Select employee, split(department,"_") from Employee

stackoverflow.com

https://prestodb.io/docs/current/functions/string.html

 

7.9. String Functions and Operators — Presto 0.232 Documentation

Splits string by entryDelimiter and keyValueDelimiter and returns a map. entryDelimiter splits string into key-value pairs. keyValueDelimiter splits each pair into key and value. Note that entryDelimiter and keyValueDelimiter are interpreted literally, i.e

prestodb.io

 

728x90

'공부' 카테고리의 다른 글

[JS] getWidth & getHeight  (0) 2020.03.14
[JS] VueJS `router-link` onclick  (0) 2020.03.14
[sh] sudo pkill cron  (0) 2020.03.10
[Python] Beautiful Soup  (0) 2020.02.27
[Python] *args  (0) 2020.02.27
댓글