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
1条答案
按热度按时间sd2nnvve1#
您可以从第一个select创建一个视图,然后使用xpath udf查询这个视图。
例如: