gpt4 book ai didi

hadoop - 我可以在创建表时在配置单元中一次使用 2 个字段终止符(如 ',' 和 '.' )吗?

转载 作者:可可西里 更新时间:2023-11-01 15:25:23 25 4
gpt4 key购买 nike

我有一个包含 idyear 的文件。我的字段由 . 分隔。有没有可能我可以使用 . 来代替终止的字段?

最佳答案

这可以使用 RegexSerDe 实现。

hive> CREATE EXTERNAL TABLE citiesr1 (id int, city_org string, ppl float) 
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
WITH SERDEPROPERTIES ('input.regex'='^(\\d+)\\.(\\S+),(\\d++.\\d++)\\t.*')
LOCATION '/user/it1/hive/serde/regex';

在上面的正则表达式中定义了三个正则表达式组。

(\\d+) leading digits is the int id column
dot . is a separator
(\\S+) - string without spaces is the city_org string column
comma , is a separator
(\\d++.\\d++) - float column
\\t - tab separator

在此处查看详细信息:https://community.hortonworks.com/articles/58591/using-regular-expressions-to-extract-fields-for-hi.html

关于hadoop - 我可以在创建表时在配置单元中一次使用 2 个字段终止符(如 ',' 和 '.' )吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47937735/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com