일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Github
- matplotlib
- PostgreSQL
- Excel
- numpy
- PySpark
- 파이썬
- GIT
- math
- Python
- list
- Mac
- Kotlin
- array
- google apps script
- dataframe
- Tkinter
- hive
- Redshift
- django
- gas
- SQL
- Google Spreadsheet
- c#
- PANDAS
- Java
- Google Excel
- Apache
- string
- Today
- Total
목록SQL/Apache Hive (35)
달나라 노트
데이터를 다루다 보면 전체에 대한 백분위를 구할 때가 있습니다. 이럴 때에는 percentile이라는 유용한 함수를 사용할 수 있습니다. Syntax percentile(column, percent) - column 백분위를 구할 데이터가 있는 대상 column - percent 상위 몇%를 의미 Table = test_table col1 col2 a 1 a 2 a 3 b 1 b 6 b 7 c 1 c 2 d 2 d 2 d 4 d 1 위같은 table이 있다고 가정합시다. select col1 , percentile(col2, 0.5) as result_col from test_table -- group by col1 ; col1 result_col a 2 b 6 c 1.5 d 2 쿼리와 결과입니다. 결과..
split 함수는 특정 문자를 구분자로 하여 문자열을 나눠줍니다. Syntax split(text, delimiter) - text 구분자를 기준으로 나눌 대상 text - delimiter 구분자 select split('1234_5678_9101', '_') as list_split , split('1234_5678_9101', '_')[0] as split_element_0 , split('1234_5678_9101', '_')[1] as split_element_1 , split('1234_5678_9101', '_')[2] as split_element_2 ; -- Result ["1234", "5678", "9101"] 1234 5678 9101 - split('1234_5678_9101', ..
Hive에서 concat() 함수는 여러 문자열을 하나로 이어주는 역할을 합니다. Syntax concat(str1, str2, str3, ...) concat() 함수는 여러 개의 parameter를 받을 수 있습니다. 그리고 string type parameter를 모두 연결해서 str1str2str3... 의 string을 return합니다. select concat('abcde, '_', '@', 'xyz', '123', '%') ; -- Result abcde_@xyz% 위처럼 모든 문자열을 연결해줍니다. select concat('_', cast(123 as string), 'abc') ; -- Result _123abc concat() 함수에 들어가는 모든 parameter는 string t..
두 시점간의 차이가 어느 정도인지를 구하는 방법은 여러 가지가 있겠지만 오늘은 unix_timestamp를 이용해 보겠습니다. unix_timestamp 함수는 어떤 timestamp 또는 timestamp_string을 unix_timestamp로 변환해주는 역할을 합니다. https://cosmosproject.tistory.com/50 Hive : unix_timestamp & from_unixtime (yyyymmdd 형태의 텍스트를 date type으로 바꾸기. 날짜와 unix_timestamp간의 unix_timestamp()의 사용법은 아래와 같습니다. unix_timestamp(날짜를 나타내는 텍스트, 날짜의 형식) 예시를 한번 봐봅시다. select unix_timestamp('2020-..