WIP: Gandiva がサポートしている関数一覧 (2019年5月時点)

(編集中)

gandiva がサポートしている操作の一覧。Haskell っぽいフォーマットで型注釈を入れた。

`num` は `int8`, `int16`, `int32`, `int64`, `uint8`, `uint16`, `uint32`, `uint64`, `float32`, `float64` のいずれか。


# 単項算術関数

```hs
not: boolean -> boolean
not(null) = null

castBIGINT: int32 -> int64
castBIGINT null = null

castFLOAT4: int32 -> float32
castFLOAT4: int64 -> float32
castFLOAT4 null = null

castFLOAT8: int32 -> float64
castFLOAT8: int64 -> float64
castFLOAT8: float32 -> float64
castFLOAT8 null = null

castDATE: int64 -> date64
castDATE null = null
```

# 二項算術関数

```hs
add: (num a) -> a -> a
add: decimal128 -> decimal128 -> decimal128
add null y = null
add x null = null

subtract: (num a) -> a -> a
subtract: decimal128 -> decimal128 -> decimal128
subtract null y = null
subtract x null = null

multiply: (num a) -> a -> a
multiply: decimal128 -> decimal128 -> decimal128
multiply null y = null
multiply x null = null

-- divide はエラーを返す可能性あり
divide: (num a) -> a -> a
divide: decimal128 -> decimal128 -> decimal128
divide null y = null
divide x null = null

mod: int64 -> int32 -> int32
mod: int64 -> int64 -> int64
mod: decimal128 -> decimal128 -> decimal128 -- エラーを返す可能性あり
mod null y = null
mod x null = null

equal: (num a) -> a -> boolean
equal: decimal128 -> decimal128 -> boolean
equal null y = null
equal x null = null

not_equal: (num a) -> a -> boolean
not_equal: decimal128 -> decimal128 -> boolean
not_equal null y = null
not_equal x null = null

less_than: (num a) -> a -> boolean
less_than: decimal128 -> decimal128 -> boolean
less_than null y = null
less_than x null = null

less_than_or_equal_to: (num a) -> a -> boolean
less_than_or_equal_to: decimal128 -> decimal128 -> boolean
less_than_or_equal_to null y = null
less_than_or_equal_to x null = null

greater_than: (num a) -> a -> boolean
greater_than: decimal128 -> decimal128 -> boolean
greater_than null y = null
greater_than x null = null

greater_than_or_equal_to: (num a) -> a -> boolean
greater_than_or_equal_to: decimal128 -> decimal128 -> boolean
greater_than_or_equal_to null y = null
greater_than_or_equal_to x null = null
```

# 日時操作

```hs
extractMillennium: date64 -> int64
extractMillennium: timestamp -> int64
extractMillennium null = null

extractCentury: date64 -> int64
extractCentury: timestamp -> int64
extractCentury null = null

extractDecade: date64 -> int64
extractDecade: timestamp -> int64
extractDecade null = null

extractYear: date64 -> int64
extractYear: timestamp -> int64
extractYear null = null

extractQuarter: date64 -> int64
extractQuarter: timestamp -> int64
extractQuarter null = null

extractMonth: date64 -> int64
extractMonth: timestamp -> int64
extractMonth null = null

extractWeek: date64 -> int64
extractWeek: timestamp -> int64
extractWeek null = null

extractDay: date64 -> int64
extractDay: timestamp -> int64
extractDay null = null

extractHour: date64 -> int64
extractHour: timestap -> int64
extractHour: time32 -> int64
extractHour null = null

extractMinute: date64 -> int64
extractMinute: timestamp -> int64
extractMinute: time32 -> int64
extractMinute null = null

extractSecond: date64 -> int64
extractSecond: timestamp -> int64
extractSecond: time32 -> int64
extractSecond null = null

extractDoy: date64 -> int64
extractDoy: timestamp -> int64
extractDoy null = null

extractDow: date64 -> int64
extractDow: timestamp -> int64
extractDow null = null

extractEpoch: date64 -> int64
extractEpoch: timestamp -> int64
extractEpoch null = null

date_trunc_Millennium: date64 -> int64
date_trunc_Millennium: timestamp -> int64
date_trunc_Millennium null = null

date_trunc_Century: date64 -> int64
date_trunc_Century: timestamp -> int64
date_trunc_Century null = null

date_trunc_Decade: date64 -> int64
date_trunc_Decade: timestamp -> int64
date_trunc_Decade null = null

date_trunc_Year: date64 -> int64
date_trunc_Year: timestamp -> int64
date_trunc_Year null = null

date_trunc_Quarter: date64 -> int64
date_trunc_Quarter: timestamp -> int64
date_trunc_Quarter null = null

date_trunc_Month: date64 -> int64
date_trunc_Month: timestamp -> int64
date_trunc_Month null = null

date_trunc_Week: date64 -> int64
date_trunc_Week: timestamp -> int64
date_trunc_Week null = null

date_trunc_Day: date64 -> int64
date_trunc_Day: timestamp -> int64
date_trunc_Day null = null

date_trunc_Hour: date64 -> int64
date_trunc_Hour: timestamp -> int64
date_trunc_Hour null = null

date_trunc_Minute: date64 -> int64
date_trunc_Minute: timestamp -> int64
date_trunc_Minute null = null

date_trunc_Second: date64 -> int64
date_trunc_Second: timestamp -> int64
date_trunc_Second null = null

-- castDATE はエラーを返す可能性がある
castDATE: utf8 -> date64
castDATE null = null

-- castTIMESTAMP はエラーを返す可能性がある
castTIMESTAMP: utf8 -> timestamp
castTIMESTAMP null = null

-- to_date は入力が不正の場合は 0 を返し、出力が不正であることを示すフラグを与える
to_date: utf8 -> utf8 -> int32 -> date64
to_date null null null = 0
```

# WIP: 日時演算

```hs
months_between

timestampdiffSecond
timestampdiffMinute
timestampdiffHour
timestampdiffDay
timestampdiffWeek
timestampdiffMonth
timestampdiffQuarter
timestampdiffYear

timestampaddSecond
timestampaddMinute
timestampaddHour
timestampaddDay
timestampaddWeek
timestampaddMonth
timestampaddQuarter
timestampaddYear

date_add
add

date_sub
subtract
date_diff
```

# ハッシュ演算

```hs
-- 32bit ハッシュ関数
hash: num -> int32
hash: date64 -> int32
hash: timestamp -> int32
hash: time32 -> int32
hash: boolean -> int32
hash: utf8 -> int32
hash: binary -> int32
hash null = 0

-- 32bit シード付きハッシュ関数
hash: (num, int32) -> int32
hash: (date64, int32) -> int32
hash: (timestamp, int32) -> int32
hash: (time32, int32) -> int32
hash: (boolean, int32) -> int32
hash: (utf8, int32) -> int32
hash: (binary, int32) -> int32
hash (null, seed) = 0

-- 32bit ハッシュ関数
hash32: num -> int32
hash32: date64 -> int32
hash32: timestamp -> int32
hash32: time32 -> int32
hash32: boolean -> int32
hash32: utf8 -> int32
hash32: binary -> int32
hash32 null = 0

-- 32bit シード付きハッシュ関数
hash32: (num, int32) -> int32
hash32: (date64, int32) -> int32
hash32: (timestamp, int32) -> int32
hash32: (time32, int32) -> int32
hash32: (boolean, int32) -> int32
hash32: (utf8, int32) -> int32
hash32: (binary, int32) -> int32
hash32 (null, seed) = 0

-- 32bit ハッシュ関数
hash32AsDouble: num -> int32
hash32AsDouble: date64 -> int32
hash32AsDouble: timestamp -> int32
hash32AsDouble: time32 -> int32
hash32AsDouble: boolean -> int32
hash32AsDouble: utf8 -> int32
hash32AsDouble: binary -> int32
hash32AsDouble null = 0

-- 32bit シード付きハッシュ関数
hash32AsDouble: (num, int32) -> int32
hash32AsDouble: (date64, int32) -> int32
hash32AsDouble: (timestamp, int32) -> int32
hash32AsDouble: (time32, int32) -> int32
hash32AsDouble: (boolean, int32) -> int32
hash32AsDouble: (utf8, int32) -> int32
hash32AsDouble: (binary, int32) -> int32
hash32AsDouble (null, seed) = 0

-- 64bit ハッシュ関数
hash64: num -> int64
hash64: date64 -> int64
hash64: timestamp -> int64
hash64: time32 -> int64
hash64: boolean -> int64
hash64: utf8 -> int64
hash64: binary -> int64
hash64 null = 0

-- 64bit シード付きハッシュ関数
hash64: (num, int64) -> int64
hash64: (date64, int64) -> int64
hash64: (timestamp, int64) -> int64
hash64: (time32, int64) -> int64
hash64: (boolean, int64) -> int64
hash64: (utf8, int64) -> int64
hash64: (binary, int64) -> int64
hash64 (null, seed) = 0

-- 64bit ハッシュ関数
hash64AsDouble: num -> int64
hash64AsDouble: date64 -> int64
hash64AsDouble: timestamp -> int64
hash64AsDouble: time32 -> int64
hash64AsDouble: boolean -> int64
hash64AsDouble: utf8 -> int64
hash64AsDouble: binary -> int64
hash64AsDouble null = 0

-- 64bit シード付きハッシュ関数
hash64AsDouble: (num, int64) -> int64
hash64AsDouble: (date64, int64) -> int64
hash64AsDouble: (timestamp, int64) -> int64
hash64AsDouble: (time32, int64) -> int64
hash64AsDouble: (boolean, int64) -> int64
hash64AsDouble: (utf8, int64) -> int64
hash64AsDouble: (binary, int64) -> int64
hash64AsDouble (null, seed) = 0
```

# WIP: 数学関数

```hs
cbrt

exp

log

log10

power: (float64, float64) -> float64

isnull

isnotnull

isnumeric

is_distinct_from

is_not_distinct_from
```

# WIP: 文字列操作

```hs
equal

not_equal

less_than

less_than_or_equal_to

greater_than

greater_than_or_equal_to

starts_with

ends_with

octet_length

bit_length

char_length

length

lengthUtf8

isnull

isnotnull

upper

like
```