zoukankan      html  css  js  c++  java
  • pig 的chararry不能用于比较的类型可以comparison operator

    pig 的chararry类型可以是由场,通过现场实地比较。


    element_id 这是chararray种类。

    声明:

    no_app_category_mapping = filter no_element_id by element_id == '' or element_id is null or element_id == '0' or element_id >='14';

    当中,element_id >='14'是错误的使用方法。

    comparison operator不能操作chararray类型。

    运行结果是 element_id为8 的被找出来了。‘8’>='14'。非常奇怪啊!


    而改成 element_id <='14'时。再运行时。

    运行结果找到了element_id =‘1’和element_id =‘11’的,说明不行。


    原理:预计是升级为bytearray,然后,按字段比較,逐个字段,所以,8>1。而1同样时。1<4

    所以11小于14。而8大于14.


    pig官网有说明:貌似仅仅能用==和!=。两边不一致是。implicit cast支持从低到高,不支持高到低。

    例如以下:

    Comparison Operators

    Description

    Operator

    Symbol

     Notes

    equal  

    ==

    not equal

    !=

    less than  

    <

    greater than

    >

    less than or equal to  

    <=

    greater than or equal to

    >=

    pattern matching  

    matches

    Takes an expression on the left and a string constant on the right.

    expression matches string-constant

    Use the Java format for regular expressions.

    Use the comparison operators with numeric and string data.

    Examples

    Numeric Example

    X = FILTER A BY (f1 == 8);
    

    String Example

    X = FILTER A BY (f2 == 'apache');
    

    Matches Example

    X = FILTER A BY (f1 matches '.*apache.*');
    

    Types Table: equal (==) operator

    bag

    tuple

    map

    int

    long

    float

    double

    chararray

    bytearray

    boolean

    datetime

    biginteger

    bigdecimal

    bag

    error

    error

    error

    error

    error

    error

    error

    error

    error

    error

    error

    error

    error

    tuple

    boolean

    (see Note 1)

    error

    error

    error

    error

    error

    error

    error

    error

    error

    error

    error

    map

    boolean

    (see Note 2)

    error

    error

    error

    error

    error

    error

    error

    error

    error

    error

    int

    boolean

    boolean

    boolean

    boolean

    error

    cast as boolean

    error

    error

    error

    error

    long

    boolean

    boolean

    boolean

    error

    cast as boolean

    error

    error

    error

    error

    float

    boolean

    boolean

    error

    cast as boolean  

    error

    error

    error

    error

    double

    boolean

    error

    cast as boolean  

    error

    error

    error

    error

    chararray

    boolean

    cast as boolean

    error

    error

    error

    error

    bytearray

    boolean

    error

    error

    error

    error

    boolean

    boolean

    error

    error

    error

    datetime

    boolean

    error

    error

    biginteger

    boolean

    error

    bigdecimal

    boolean

    Note 1: boolean (Tuple A is equal to tuple B if they have the same size s, and for all 0 <= i < s A[i] == B[i])

    Note 2: boolean (Map A is equal to map B if A and B have the same number of entries, and for every key k1 in A with a value of v1, there is a key k2 in B with a value of v2, such that k1 == k2 and v1 == v2)


    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    设计模式(一)基础面向对象
    面试题之三门问题
    「巫师3(The Witcher 3:Wild Hunt)」游戏测评
    欧拉角和四元数
    struts标签遍历各种list Map
    浅谈HtmlCleaner+XPath解析html或者xml
    hadoop简单例子
    解决JSP参数传递乱码的问题
    Set、List、Map的区别(浅谈)
    做个犀利的码农
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4655236.html
Copyright © 2011-2022 走看看