简体   繁体   English

Hive SQL:如何将单个字段拆分为具有定义长度的多个列?

[英]Hive SQL: How to split a single field into multiple columns with defined length?

For example: string = 'ABCDEFGHIJ'例如:字符串 = 'ABCDEFGHIJ'

Now, need to split the string to multiple columns with length of 4现在,需要将字符串拆分为长度为 4 的多列

Desired Output:所需的 Output:

Col1   Col2   Col3
'ABCD' 'EFGH' 'IJ'

You can use substr() :您可以使用substr()

select substr(col, 1, 4) as col1, substr(col, 5, 4) as col2, substr(col, 9, 4) as col3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM