将数据拆分成Hive中的多个列 [英] Splitting data into multiple columns in Hive
问题描述
输入数据示例: 如何将数据字符串拆分为Hive表中的3个独立列? / code>。拆分为 需要的输出: 查询: 输出: 您需要替换116:151:1 与表格中列的名称。 How can I split a data string into 3 separate columns in a Hive table? Example input data: Required output:
Use the Query: Output: You'll want to replace "116:151:1" with the name of the column in your table. 这篇关于将数据拆分成Hive中的多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 116:151:1
gid,sid,rid
。
gid sid rid
116 151 1
split()
函数。您可以在文档中阅读它(以及所有其他Hive函数) 。
select split(116:151:1,'\\:')[0]作为gid
,split(116:151:1,'\\:')[1] as sid
,split(116:151:1,'\\:')[2]作为rid
from database.table
gid sid rid
116 151 1
116:151:1
. Split as gid, sid, rid
.gid sid rid
116 151 1
split()
function. You can read about it (and all other Hive functions) in the documentation.select split("116:151:1", '\\:')[0] as gid
, split("116:151:1", '\\:')[1] as sid
, split("116:151:1", '\\:')[2] as rid
from database.table
gid sid rid
116 151 1