日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

pig 的chararry类型不能用比较运算符comparison operator

發布時間:2025/5/22 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)


轉載于:https://www.cnblogs.com/cl1024cl/p/6205409.html

總結

以上是生活随笔為你收集整理的pig 的chararry类型不能用比较运算符comparison operator的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。