<store>
   <book id="book"><title id="titile">hive</title><price id="pri">10</price>
   </book>
   <fruit id="shuiguo">
       <apple id="shuiguo1"><name>apple</name><price>5</price></apple>
       <pear  id="shuiguo2"><name>pear</name><price>3.5</price></pear>
   </fruit>
</store>

-----------------------------

  • xpath returns a Hive array of strings.
  • xpath_string returns a string.
  • xpath_boolean returns a boolean.
  • xpath_short returns a short integer.
  • xpath_int returns an integer.
  • xpath_long returns a long integer.
  • xpath_float returns a floating point number.
  • xpath_double,xpath_number returns a double-precision floating point number (xpath_number is an alias for xpath_double).

路径表达式  //  从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置

                   @  选取属性

                   . 当前节点

                   ..当前节点的父节点

hive> select xpath('<store><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//@id');
OK
_c0
["book","titile","pri","shuiguo","shuiguo1","shuiguo2"]
Time taken: 0.144 seconds, Fetched: 1 row(s)

路径表达式  //  从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置

hive> select xpath('<store><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','store//text()');
OK
_c0
["hive","10","apple","5","pear","3.5"]
Time taken: 0.171 seconds, Fetched: 1 row(s)

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//text()');
OK
_c0
["hive","10","apple","5","pear","3.5"]
Time taken: 0.145 seconds, Fetched: 1 row(s)

路径表达式  / 从根节点选取

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','store/*[@id="shuiguo"]/@id');
OK
_c0
["shuiguo"]
Time taken: 0.154 seconds, Fetched: 1 row(s)

路径表达式  //  从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置
hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','store/*[@id="shuiguo"]//@id');
OK
_c0
["shuiguo","shuiguo1","shuiguo2"]
Time taken: 0.163 seconds, Fetched: 1 row(s)

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//fruit//text()');
OK
_c0
["apple","5","pear","3.5"]
Time taken: 0.556 seconds, Fetched: 1 row(s)

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//apple//text()');
OK
_c0
["apple","5"]
Time taken: 0.572 seconds, Fetched: 1 row(s)

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//apple//@id');
OK
_c0
["shuiguo1"]
Time taken: 0.175 seconds, Fetched: 1 row(s)

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','store/*[@id="shuiguo"]//text()');
OK
_c0
["apple","5","pear","3.5"]
Time taken: 0.149 seconds, Fetched: 1 row(s)

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//title[@id="titile"]/text()');
OK
_c0
["hive"]
Time taken: 0.149 seconds, Fetched: 1 row(s)
hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//title[@id="titile"]/@id');
OK
_c0
["titile"]
Time taken: 0.156 seconds, Fetched: 1 row(s)
hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','//fruit[@id="shuiguo"]//text()');
OK
_c0
["apple","5","pear","3.5"]
Time taken: 0.146 seconds, Fetched: 1 row(s)

---------------------------------------------------------------------

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','store/book[price>10]//text()');
OK
_c0
[]
Time taken: 0.157 seconds, Fetched: 1 row(s)
hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><apple id="shuiguo1"><name>apple</name><price>5</price></apple><pear id="shuiguo2"><name>pear</name><price>3.5</price></pear></fruit></store>','store/book[price>3]//text()');
OK
_c0
["hive","10"]
Time taken: 0.156 seconds, Fetched: 1 row(s)

---------------------------------------

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><shuiguo id="shuiguo1"><name>apple</name><price>5</price></shuiguo><shuiguo id="shuiguo2"><name>pear</name><price>3.5</price></shuiguo></fruit></store>','store/fruit/shuiguo[price>3]//text()');
OK
_c0
["apple","5","pear","3.5"]
Time taken: 0.137 seconds, Fetched: 1 row(s)
hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><shuiguo id="shuiguo1"><name>apple</name><price>5</price></shuiguo><shuiguo id="shuiguo2"><name>pear</name><price>3.5</price></shuiguo></fruit></store>','store/fruit/shuiguo[price>4]//text()');
OK
_c0
["apple","5"]
Time taken: 0.136 seconds, Fetched: 1 row(s)

-------------------------------------------------

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><shuiguo id="shuiguo1"><name>apple</name><price>5</price></shuiguo><shuiguo id="shuiguo2"><name>pear</name><price>3.5</price></shuiguo></fruit></store>','store/*/@id');
OK
_c0
["book","shuiguo"]
Time taken: 0.143 seconds, Fetched: 1 row(s)
hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><shuiguo id="shuiguo1"><name>apple</name><price>5</price></shuiguo><shuiguo id="shuiguo2"><name>pear</name><price>3.5</price></shuiguo></fruit></store>','store/*/text()');
OK
_c0
[]
Time taken: 0.152 seconds, Fetched: 1 row(s)

----------------------------------------------

hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><shuiguo id="shuiguo1"><name>apple</name><price>5</price></shuiguo><shuiguo id="shuiguo2"><name>pear</name><price>3.5</price></shuiguo></fruit></store>','store/fruit//text()');
OK
_c0
["apple","5","pear","3.5"]
Time taken: 0.164 seconds, Fetched: 1 row(s)
hive> select xpath('<store id="shangdian"><book id="book"><title id="titile">hive</title><price id="pri">10</price></book><fruit id="shuiguo"><shuiguo id="shuiguo1"><name>apple</name><price>5</price></shuiguo><shuiguo id="shuiguo2"><name>pear</name><price>3.5</price></shuiguo></fruit></store>','//text()');
OK
_c0
["hive","10","apple","5","pear","3.5"]
Time taken: 0.14 seconds, Fetched: 1 row(s)

------------------------------------------------------------------------

hive xml udf的更多相关文章

  1. Hive 10、Hive的UDF、UDAF、UDTF

    Hive自定义函数包括三种UDF.UDAF.UDTF UDF(User-Defined-Function) 一进一出 UDAF(User- Defined Aggregation Funcation) ...

  2. hive premanent udf 发布...

    起因: hive premanent udf 发布成功,但是hue 无法加载使用(但是cli 是可用的) ,处理半天,依然不可用!后来发现重启hiveserver2 就可以了     具体步骤如下:  ...

  3. hive中UDF、UDAF和UDTF使用

    Hive进行UDF开发十分简单,此处所说UDF为Temporary的function,所以需要hive版本在0.4.0以上才可以. 一.背景:Hive是基于Hadoop中的MapReduce,提供HQ ...

  4. hive下UDF函数的使用

    1.编写函数 [java] view plaincopyprint?package com.example.hive.udf;    import org.apache.hadoop.hive.ql. ...

  5. 在hive中UDF和UDAF使用说明

    Hive进行UDF开发十分简单,此处所说UDF为Temporary的function,所以需要hive版本在0.4.0以上才可以. 一.背景:Hive是基于Hadoop中的MapReduce,提供HQ ...

  6. 【转】hive中UDF、UDAF和UDTF使用

    原博文出自于: http://blog.csdn.net/liuj2511981/article/details/8523084 感谢! Hive进行UDF开发十分简单,此处所说UDF为Tempora ...

  7. hive的UDF读取配置文件

    hive的UDF读取配置文件 实现步骤 在读取配置文件的写为./file_name,然后在添加UDF的时候把配置文件也加入资源就好了: add jar xxx.jar; add file file_n ...

  8. hive添加UDF

    hive添加UDF 步骤如下: 函数分为永久和临时函数,后者会话退出则消失,前者不会 查看已有函数(创建好后也可以通过这个来查看是否成功) show functions; 写UDF的java文件,如: ...

  9. Impala 加载Hive的UDF

    Impala的UDF有两种: Native Imapal UDF:使用C++开发的,性能极高,官方性能测试比第二种高出将近10倍 Hive的UDF:是Hive中的UDF,直接加载到Impala中,优点 ...

随机推荐

  1. List<Map<String, Integer>> 同key的value全部累加合并

    public static void main(String[] args){ List<Map<String,Object>> list1 = new ArrayList&l ...

  2. 微软更新导致的IIS7设置默认主页无效

    近期两个superKM的老客户出现问题,网站不能自动检索默认文档,必须通过完整网址才能访问. 值得一提的是出现问题的都是 IIS7 和7.5版本,服务器为windows server2008 R2. ...

  3. linux系统的启动过程及系统初始化

    (其中/etc/inittab是一个很重要的文件,值得细究http://www.2cto.com/os/201108/98426.html) 其开头的446字节内容特指为"主引导记录&quo ...

  4. IBM DS存储存储性能调优

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jaminwm/article/details/26458791 ibm存储适用,其它存储有相似參数. ...

  5. 51nod 1934 受限制的排列——笛卡尔树

    题目:http://www.51nod.com/Challenge/Problem.html#!#problemId=1934 根据给出的信息,可以递归地把笛卡尔树建出来.一个点只应该有 0/1/2 ...

  6. MySQL 查看编码 排序规则

    查看数据库的排序规则 mysql> show variables like 'collation%'; +----------------------+-------------------+ ...

  7. git 不能拉取时,检查是不是被杀毒软件给干掉了

    我这儿是 \Git\bin\sh.exe 被干掉了. 添加排除,并从隔离区中还原.

  8. Java高并发综合

    这篇文章是研一刚入学时写的,今天整理草稿时才被我挖出来.当时混混沌沌的面试,记下来了一些并发的面试问题,很多还没有回答.到现在也学习了不少并发的知识,回过头来看这些问题和当时整理的答案,漏洞百出又十分 ...

  9. 本地ip 和 网络ip 解释

    本地IP其实就是私有IP地址10.0.0.0--10.255.255.255172.16.0.0----172.31.255.255192.168.0.0---192.168.255.255 这些都是 ...

  10. [转]SQL Server 中 Cast 与 Convert

    两者都用于:将一种数据类型的表达式转换为另一种数据类型的表达式. 安装有 Sql Server 2008 时可以浏览:ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.zh-C ...