<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. http协议详谈

    scheme - 定义因特网服务的类型.最常见的类型是 httphost - 定义域主机(http 的默认主机是 www)domain - 定义因特网域名,比如 runoob.comport - 定义 ...

  2. 【BZOJ2683】简单题

    cdq分治妙啊 (被改过题面的)原题: dydxh所出的题目是这样的:有一个N*N矩阵,给出一系列的修改和询问,修改是这样的:将(x,y)中的数字加上k,而询问是这样的:求(x1,y1)到(x2,y2 ...

  3. Oracle集合类型

    Oracle集合类型介绍   集合类型   1. 使用条件:    a. 单行单列的数据,使用标量变量 .     b. 单行多列数据,使用记录    c. 单列多行数据,使用集合        *集 ...

  4. oracle 与sql serve 获取随机行数的数据

    Oracle 随机获取N条数据    当我们获取数据时,可能会有这样的需求,即每次从表中获取数据时,是随机获取一定的记录,而不是每次都获取一样的数据,这时我们可以采取Oracle内部一些函数,来达到这 ...

  5. Google Android API官网封杀了,没法查android技术资料的3种解决方式

    1.从uhdesk上訪问简化版android api在线文档(反应速度极快) http://www.uhdesk.com/simpleandroidoc/index.html   2.下载chm本地文 ...

  6. ASP.NET MVC中如何实现页面跳转

    1,最简单的方式:超链接 以下分别是连接到HomeController控制器下的SharpL动作方法,以及百度首页.代码如下: <a href="Home\SharpL"&g ...

  7. php递归函数return会出现无法正确返回想要值的情况

    php递归函数中使用return的时候会碰到无法正确返回想要的值得情况,如果不明白其中的原因,很难找出错误的,就下面的具体例子来说明一下吧: 1 2 3 4 5 6 7 8 9 function te ...

  8. 开发vue全局插件的4种方式

    定义全局插件的步骤 定义全局插件 pluginsUtil.js Vue.js 的插件应当有一个公开方法 install .这个方法的第一个参数是 Vue 构造器,第二个参数是一个可选的选项对象: ex ...

  9. WIN7\win10下使用批处理配置JAVA环境变量

    我找了很多环境变量批处理的教程,都不太满意,因此综合修改了下,拼凑出了这么一个版本. 下面这个是我主要参考的博客,大部分的代码都是来自这里: http://blog.csdn.net/lpy36543 ...

  10. android调节音量——AudioManager的应用

    Android中可以通过程序获取系统手机的铃声和音量.同样,也可以设置铃声和音量.android中给出了AudioManager类来实现音量获取.音量控制. 本篇基于 Android API 中的 A ...