Specialized Functions
Vadalog provides a comprehensive library of specialized functions for mathematical operations, hashing, date/time manipulation, type casting, and interval checks.Mathematical Functions
| Function | Signature | Description |
|---|---|---|
math:mod() | (dividend, divisor) → number | Modulo operation |
math:sqrt() | (x) → double | Square root |
math:abs() | (x) → number | Absolute value |
math:round() | (x, scale?) → number | Round to nearest integer or decimal places |
math:bround() | (x, scale?) → number | Banker’s rounding (round to nearest even) |
math:min() | (v1, v2, …) → same type | Minimum value |
math:max() | (v1, v2, …) → same type | Maximum value |
math:log() | (x) → double | Natural logarithm |
math:log10() | (x) → double | Base-10 logarithm |
math:pow() | (base, exponent) → double | Power (exponentiation) |
math:exp() | (x) → double | Exponential (e^x) |
math:ceil() | (x) → number | Round up to nearest integer |
math:floor() | (x) → number | Round down to nearest integer |
math:sin() | (x) → double | Sine |
math:cos() | (x) → double | Cosine |
math:tan() | (x) → double | Tangent |
math:uniform() | (upperBound) → number | Random integer [0, upperBound) |
math:rand() | () → double | Random double [0, 1) |
math:PI() | () → double | Pi constant |
math:E() | () → double | Euler’s number |
Hash Functions
| Function | Signature | Description |
|---|---|---|
hash:hash() | (v1, v2, …) → int | 32-bit Spark hash |
hash:sha1() | (value) → string | SHA-1 hash |
hash:md5() | (value) → string | MD5 hash |
hash:sha2() | (v1, …, bitLength) → string | SHA-2 hash (256, 384, 512 bits) |
Date and Time Functions
| Function | Signature | Description |
|---|---|---|
date:current_date() | () → date | Current date |
date:current_timestamp() | () → timestamp | Current timestamp |
date:next_day() | (date) → date | Add one day |
date:prev_day() | (date) → date | Subtract one day |
date:add() | (date, days) → date | Add N days |
date:sub() | (date, days) → date | Subtract N days |
date:diff() | (end, start) → int | Difference in days |
date:spec_day() | (text "MMM-yyyy") → string | Parse date with format |
date:to_timestamp() | (text, format) → timestamp | Parse string to timestamp |
date:format() | (dateOrTs, pattern) → string | Format to string |
Type Casting Functions
| Function | Signature | Description |
|---|---|---|
as_string() | (value) → string | Cast to string |
as_int() | (value) → int | Cast to integer |
as_long() | (value) → long | Cast to long |
as_double() | (value) → double | Cast to double |
as_float() | (value) → float | Cast to float |
as_boolean() | (value) → boolean | Cast to boolean |
as_date() | (value) → date | Cast to date |
as_timestamp() | (value) → timestamp | Cast to timestamp |
as_json() | (value) → string | Cast to JSON string |
as_list() | (value, elementType) → list | Cast to list |
as_set() | (value, elementType) → set | Cast to set |
as_map() | (keys, values, types) → map | Cast to map |
Interval Operators
| Function | Bounds | Returns true for |
|---|---|---|
between(v, min, max) | Exclusive both | min < v < max |
_between(v, min, max) | Left inclusive | min <= v < max |
between_(v, min, max) | Right inclusive | min < v <= max |
_between_(v, min, max) | Both inclusive | min <= v <= max |

