<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. 【转载】Python字符串操作之字符串分割与组合

    1. str.split():字符串分割函数 通过指定分隔符对字符串进行切片,并返回分割后的字符串列表. 语法: str.split(s, num)[n] 参数说明: s:表示指定的分隔符,不写的话, ...

  2. idea_快捷键default&eclipse

    关键字: SpringMybatisplusRedisApplicationTests github关键字(springboot拦截器完整项目): implements WebMvcConfigure ...

  3. LG3684 [CERC2016]机棚障碍 Hangar Hurdles

    题意 题目描述 你正在评估一些关于一个巨型飞机仓库的建设计划.飞机仓库的地面可以表示为n行n列的网格图,其中每个格子要么是空的,要么有障碍物.行从上到下依次被编号为1到n,列从左到右依次被编号为1到n ...

  4. sdut2165 Crack Mathmen (山东省第二届ACM省赛)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/svitter/article/details/24270265 本文出自:http://blog.c ...

  5. TensorFlow笔记-05-反向传播,搭建神经网络的八股

    TensorFlow笔记-05-反向传播,搭建神经网络的八股 反向传播 反向传播: 训练模型参数,在所有参数上用梯度下降,使用神经网络模型在训练数据上的损失函数最小 损失函数:(loss) 计算得到的 ...

  6. dongle0

    *CLI> -- [dongle0] Trying to connect on /dev/ttyUSB2... 插拔dongle[Jan 13 23:42:20] WARNING[3443]: ...

  7. JUC线程池之 线程池架构

    线程池的架构图如下: Executor 它是"执行者"接口,它是来执行任务的.准确的说,Executor提供了execute()接口来执行已提交的 Runnable 任务的对象.E ...

  8. <<APUE>> 编译方法

    /********************************************************************************第0种-最简单实用********** ...

  9. Mac 配置多jdk 随意切换

    1下载安装 jdk6:https://support.apple.com/kb/DL1572?locale=zh_CN 2配置环境变量 open .bash_profile export PATH=$ ...

  10. RegExp实例

    ECMAScript通过RegExp类型来支持正则表达式,常见的正则表达式为:var expression = /pattern / flags;其中的模式(pattern)部分可以使任何简单或复杂的 ...