SQL/Apache Hive
Hive : concat() (문자열 연결하기)
CosmosProject
2023. 10. 13. 19:17
728x90
반응형
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 type이어야 합니다.
123같은 숫자가 있으면 에러가 발생하므로 숫자를 string으로 바꿔준 후 parameter로 전달해야 합니다.
728x90
반응형