0
我试图解析一些存储在Hive表中的数据。在配置单元中使用Xpath
比方说。
Hive> SELECT * FROM fulldatatable LIMIT 1;
SELECT xpath('xml data from the previous command') SELECT src LIMIT 1;
我的问题是如何加载第一个在xpath
查询?
感谢,
我试图解析一些存储在Hive表中的数据。在配置单元中使用Xpath
比方说。
Hive> SELECT * FROM fulldatatable LIMIT 1;
SELECT xpath('xml data from the previous command') SELECT src LIMIT 1;
我的问题是如何加载第一个在xpath
查询?
感谢,
您可以创建从第一选择一个view,然后查询这个与XPath的UDF。
E.g:
Initial tables:
hive> describe table1;
id int
f1 string
f2 string
f3 string
f4 string
hive> select * from table1;
1 <a> <b>1</b> <b>1</b> </a>
2 <a> <b>1</b> <b>2</b> </a>
3 <a> <b>1</b> <b>3</b> </a>
Another table:
hive> describe ranks;
id int
text string
hive> select * from ranks;
1 good
2 bad
3 worst
Create a view:
hive> create view xmlout(id, line) as select id, concat(f1,f2,f3,f4) from table1;
Then:
hive> select xpath_short(x.line, 'sum(a/b)'), r.text from xmlout x
join ranks r on (x.id = r.id);
2 good
3 bad
4 worst