Vadalog provides a comprehensive library of specialized functions for mathematical operations, hashing, date/time manipulation, type casting, and interval checks.
Mathematical Functions
math:mod()
Modulo operation:
Example:
math:sqrt()
Square root:
Example:
math:abs()
Absolute value:
Example:
math:round()
Round to nearest integer or specified decimal places:
Example:
math:bround()
Banker’s rounding (round to nearest even):
Example:
math:min() / math:max()
Find minimum or maximum value:
Example:
math:log()
Natural logarithm:
Example:
math:log10()
Base-10 logarithm:
Example:
math:pow()
Power (exponentiation):
Example:
math:exp()
Exponential (e^x):
Example:
math:ceil() / math:floor()
Round up or down to nearest integer:
Example:
math:sin() / math:cos() / math:tan()
Trigonometric functions:
Example:
Generate random numbers:
Example:
math:PI() / math:E()
Mathematical constants:
Example:
Hash Functions
Generate hash values for data integrity and security.
hash:hash()
Generate 32-bit Spark hash:
Example:
hash:sha1()
Generate SHA-1 hash:
Example:
hash:md5()
Generate MD5 hash:
Example:
hash:sha2()
Generate SHA-2 hash with specified bit length:
Examples:
Date and Time Functions
date:current_date() / date:current_timestamp()
Get current date or timestamp:
Example:
date:next_day() / date:prev_day()
Add or subtract one day:
Example:
date:add() / date:sub()
Add or subtract days:
Example:
date:diff()
Calculate difference in days:
Example:
date:spec_day()
Parse date with specific format:
Example:
date:to_timestamp()
Parse string to timestamp:
Example:
Format date or timestamp to string:
Example:
Type Casting Functions
Convert values between different data types.
as_string()
Cast to string:
Example:
as_int() / as_long()
Cast to integer or long:
Example:
as_double() / as_float()
Cast to double or float:
Example:
as_boolean()
Cast to boolean:
Example:
as_date() / as_timestamp()
Cast to date or timestamp:
Example:
as_json()
Cast to JSON string:
Example:
as_list()
Parse a JSON array string into a typed Spark array. Accepts two forms:
When the second argument is a simple type (e.g., "string", "integer"), the JSON array elements are cast to that type. When it contains : characters, it is parsed as a struct schema — each JSON object in the array is parsed into a struct with the declared fields.
Simple type example:
Struct schema example (e.g., Qdrant ask() results):
Schema rules:
- Fields are matched by name, not by position — the order of fields in the schema does not need to match the JSON.
- You only need to declare the fields you want to extract. Omitted fields are ignored.
- Supported types:
string, double, integer, long, float, boolean, date, timestamp.
as_struct()
Parse a single JSON object string into a typed Spark struct:
Same schema format as as_list, but for a single JSON object (not an array). Returns a struct directly.
Example:
as_list vs as_structUse as_list when the JSON is an array of objects (e.g., [{...}, {...}]). Use as_struct when the JSON is a single object (e.g., {...}). Both use the same "field:type, ..." schema format and both match fields by name.
as_set()
Parse a JSON array string into a typed Spark array with duplicates removed:
Example:
as_map()
Cast to a map type:
Interval Operators
Check if values fall within specified ranges.
between()
Exclusive on both ends:
Example:
_between()
Inclusive left, exclusive right:
Example:
between_()
Exclusive left, inclusive right:
Example:
_between_()
Inclusive on both ends:
Example:
Null Handling Functions
is_null()
Check if a value is null:
Example:
Expected output:
is_not_null()
Check if a value is not null:
Example:
Expected output:
nullManagement:ifnull()
Return a fallback value when an expression is null, or a different value when it is not null:
Example:
Expected output:
nullManagement:coalesce()
Return the first non-null value from a list of expressions:
Example:
Expected output:
Utility Functions
struct()
Create structured data by pairing keys with values:
Example:
struct:get()
Extract a field value from a struct by its field name:
Example:
Expected output:
uuid()
Generate universally unique identifiers:
Examples:
monotonically_increasing_id()
Generate monotonically increasing IDs:
Example:
utils:phone_number()
Format phone numbers with optional regional context:
Examples:
Anonymization Functions
Privacy-preserving data operations.
mask()
Mask sensitive data for privacy protection:
Masks the given string value by replacing characters with configurable mask characters. The function replaces characters with ‘X’ or ‘x’, and numbers with ‘n’ by default. This is useful for creating copies of tables with sensitive information removed.
Arguments:
input - string value to mask (STRING, VARCHAR, CHAR)
upperChar - character to replace upper-case characters with. Specify NULL to retain original character. Default: ‘X’
lowerChar - character to replace lower-case characters with. Specify NULL to retain original character. Default: ‘x’
digitChar - character to replace digit characters with. Specify NULL to retain original character. Default: ‘n’
otherChar - character to replace other characters with. Specify NULL to retain original character
Examples:
anonymization:risk()
Calculate privacy risk score:
Example:
anonymization:msu()
Calculate MSU score:
Example:
Kalman Filter Functions
Advanced signal processing and fault detection.
kalmanFilter:fault()
Detect faults using Kalman filter:
Extract values from Kalman filter input: