问题描述
我在HDFS中有一个固定长度的文件,其中我必须使用正则表达式创建外部表。
我的文件是这样的:
12piyush34stack10
13pankaj21abcde41
我希望它将它转换为表格:
key_column Value_column
---------- -----------------
1234stack 12piyush34stack10
1321stack 13pankaj21abcde41
我甚至通过substr使用insert尝试过,但我无法指向key_columns。
请帮助解决这个问题。
我不知道你为什么使用regexp外部表,但是如果我,我会创建一个正则表达式serde表,然后创建两列(key_column,Value_column),然后创建两个列(key_column,Value_column)如下所示指定serde选项:
输出选项将按空间顺序将空格分隔的数据写入相应的列。
尚未测试它,请注意,在java中,反斜杠可能无法正确解释。
I have a fixed length file in HDFS on top of which i have to create external table using regex.My file is something like this:
12piyush34stack10
13pankaj21abcde41
I want it to convert it into a table like:
key_column Value_column
---------- -----------------
1234stack 12piyush34stack10
1321stack 13pankaj21abcde41
I tried even by substr using insert but i am unable to point to key_columns.Please help with solving this problem.
I don't know why you've used regexp external table but the way cannot workout so as to need also use another substring operation.
If me , I would make a regexp serde table then create two columns(key_column , Value_column) and just specify serde option as follows:
The output option will write the space separated data to corresponding columns by order.
Haven't yet test it , mind the back slash may not interpreted right in java.
这篇关于创建用于处理固定长度文件的Hive表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!