zoukankan      html  css  js  c++  java
  • hive xml udf

    <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)

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

  • 相关阅读:
    Git 远程分支的查看及相关问题
    Clean Code – Chapter 6 Objects and Data Structures
    Clean Code – Chapter 5 Formatting
    Clean Code – Chapter 4: Comments
    利用 SerialPort 控件实现 PC 串口通信
    Clean Code – Chapter 3: Functions
    oracle如何查看当前有哪些用户连接到数据库
    c++ Ansi和Unicode相互转换
    c++ Utf8和Unicode相互转换
    c++ 根据某个字符或者字符串分割另外一个字符串
  • 原文地址:https://www.cnblogs.com/playforever/p/8967732.html
Copyright © 2011-2022 走看看