<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. 一篇文章入门Jmeter性能测试【经典长文】

    孟船长  目录 1.性能测试定义2.为什么要做性能测试3.性能测试指标.性能测试分类4.Jmeter性能测试实战[入门级]5.参考文章链接 1.性能测试定义 百度&知乎 性能测试是通过自动化的 ...

  2. DataFrame 列运算

    import pandas as pd import StringIO table_buffer = StringIO.StringIO('''a b 2007-01-08 0.786667 270 ...

  3. ORTP库移植

    转载,侵删 1.ORTP的引入 为什么要使用RTP:http://blog.51cto.com/ticktick/462746RTP协议分析:http://www.xuebuyuan.com/7399 ...

  4. nginx 配置 vhosts 的方案

    网上有很多种 nginx 配置 vhosts,来个比较方便的. 步骤如下: 在 conf 目录建一个vhosts 目录. 在 nginx.conf 末尾加入 include vhosts/*.conf ...

  5. java 多线程之:sleep() 方法

    sleep()介绍 sleep() 定义在java.lang.Thread中. sleep() 的作用是让当前线程休眠,即当前线程会从"运行状态"进入到"休眠(阻塞)状态 ...

  6. redux学习与使用

    Redux: 主要概念Action,reducer,store,state 原理:dispatch ({ type:action, preload: { val } } ) --->reduce ...

  7. golang channel 的使用

    本文对channel使用中的几个疑惑,以例子的形式加以说明. 普通channel 缺省情况下,发送和接收会一直阻塞着,直到另一方准备好. 例如: package main import ( " ...

  8. JQuery获得内容 - text()、html() 以及 val()

    获得text()和html() <!DOCTYPE html><html><head><script src="/jquery/jquery-1.1 ...

  9. MVC框架请求处理

    为开发团队选择一款优秀的MVC框架是件难事儿,在众多可行的方案中决择需要很高的经验和水平.你的一个决定会影响团队未来的几年.要考虑方面太多: 简单易用,以提高开发效率.使小部分的精力在框架上,大部分的 ...

  10. <<APUE>> 线程的分离状态

    在任何一个时间点上,线程是可结合的(joinable),或者是分离的(detached).一个可结合的线程能够被其他线程收回其资源和杀死:在被其他线程回收之前,它的存储器资源(如栈)是不释放的.相反, ...