Conditional
When you import conditional Alteryx functions into Prophecy, the logic of your formulas stays the same, but the syntax changes, because SQL engines usecase expressions instead of IF/IIF/Switch. Prophecy’s import makes these conversions for you.
When reading or debugging generated SQL, you should recognize the case functions below as the SQL equivalent of Alteryx’s conditional functions.
| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
IF c THEN t ELSE f ENDIF | case when then else end | case_when is equivalent to if; endif is equivalent to END. |
IF c THEN t ELSEIF c2 THEN t2 ELSE f ENDIF | case when c then t when c2 then t2 else f end | case_when is equivalent to if; endif is equivalent to end. In Alteryx, you chain conditions with elseif. in SQL, each elseif becomes another when … then …. |
IIF | case when c then t else f end | In Alteryx, iff serves as a shorthand for if ... else. In SQL, iff is equivalent to a case with one condition. |
SWITCH | case when c then t when c2 then t2 ... end | In Alteryx, switch tests one case against several possibilities. In SQL, this is expressed as a case with multiple when … then … clauses. |
Conversions
Alteryx provides many specialized conversion functions. SQL engines rely on general-purpose casting, encoding and decoding functions, and numeric conversion functions.- BigQuery provides safer casting via
safe_cast, which returnsnullinstead of failing. - Snowflake provides error-handling conversion functions such as
try_castandtry_to_number, which returnnullwhen conversion fails. - Databricks SQL supports
conv()for base conversions, but BigQuery and Snowflake do not have the same general-purpose base conversion function.
- Databricks SQL
- BigQuery
- Snowflake
| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
BinToInt | conv(expr, from_base, to_base) | Databricks uses conv for base conversions. |
CharFromInt | char() | char is equivalent to CharFromInt in Alteryx. |
CharToInt | ascii() | ascii is equivalent to CharToInt in Alteryx. |
ConvertFromCodePage | convertFromCodePage() | Functions are equivalent; note slightly different case in SQL function name. |
HexToNumber | conv() | Databricks uses conv for base conversions. |
IntToBin | bin() | Databricks uses bin for binary conversions. |
IntToHex | conv() | Databricks uses conv for base conversions. |
ToDegrees | degrees() | Exact mapping. |
ToNumber | regexp_extract() | In Databricks, ToNumber is approximated with regexp_extract. This extracts numeric substrings. |
ToRadians | radians() | Exact mapping. |
ToString | cast(col as string) | Converts to a string. |
DateTime
Alteryx provides many specialized datetime functions. The SQL mapping depends on the target engine. Databricks SQL, BigQuery, and Snowflake all support broad datetime functionality, but they differ in function names, argument order, return types, format patterns, and time zone behavior.- Databricks SQL
- BigQuery
- Snowflake
| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
DateTimeAdd | date_add() or ts + interval ... or add_months() | date_add only adds days. For other units, use interval expressions or add_months() depending on the unit. |
DateTimeDay | day() | Exact mapping. |
DateTimeDiff | datediff() | Returns date differences. For finer units, use timestamp or interval expressions. |
DateTimeFirstOfMonth | date_trunc() | Exact mapping. |
DateTimeFormat | date_format(ts, 'pattern') | Formats date or timestamp values as strings. |
DateTimeHour | hour() | Exact mapping. |
DateTimeLastOfMonth | last_day() | Exact mapping. |
DateTimeMinutes | minute() | Exact mapping. |
DateTimeMonth | month() | Exact mapping. |
DateTimeNow | current_timestamp() | Exact mapping. |
DateTimeNowPrecise | current_timestamp() | Exact mapping. |
DateTimeParse | to_date() or to_timestamp() | Use to_timestamp() when the parsed value needs to retain time information. |
DateTimeQuarter | quarter() | Exact mapping. |
DateTimeSeconds | second() | Exact mapping. |
DateTimeToday | current_date() | Exact mapping. |
DateTimeToUTC | to_utc_timestamp(ts, tz) | Converts a timestamp from the specified time zone to UTC. |
DateTimeTrim | date_trunc() | Exact mapping. |
DateTimeYear | year() | Exact mapping. |
ToDate | to_date() | Converts to a date. |
ToDateTime | to_timestamp() | Outputs a SQL timestamp. |
Math
Alteryx offers a large catalog of dedicated math functions, many of which map directly to Databricks SQL. Most Alteryx functions have 1:1 equivalents, with a few cases (random integers, logs) requiring light SQL expressions to reproduce exact behavior.| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
ABS | abs() | Exact mapping. |
ACOS | acos() | Exact mapping. |
ASIN | asin() | Exact mapping. |
ATAN | atan() | Exact mapping. |
ATAN2 | atan2() | Exact mapping. |
Average | avg() | avg ignores nulls. Use AVG(col) with COALESCE(col, 0) to treat nulls as 0. |
AverageNonNull | avg() | avg ignores nulls by default. |
CEIL | ceil() | Exact mapping. |
COS | cos() | Exact mapping. |
COSH | cosh() | Exact mapping. |
DISTANCE | haversine() | Exact mapping. |
EXP | exp() | Exact mapping. |
FACTORIAL | factorial() | Exact mapping. |
FLOOR | floor() | Exact mapping. |
LOG | ln() | Alteryx LOG() returns the natural log (ln). In SQL, ln(x) is the natural log and log10(x) is base-10. Databricks SQL also supports arbitrary bases via log(base, x). |
LOG10 | log10() | Exact mapping.. |
Median | median | Exact mapping. |
Mod | mod() | Exact mapping. |
PI | pi() | Exact mapping. |
POW | pow() | Exact mapping. |
RAND | rand() | Exact mapping. |
RandInt | rand() | Alteryx RandInt returns an integer in an inclusive range. Databricks rand() returns a DOUBLE drawn uniformly from the interval [0, 1), meaning it can return 0 but will never return 1. To mimic RandInt(low, high) exactly, use cast(floor(rand() * (high - low + 1)) + low as int). |
Round | round() | Exact mapping. |
SIN | sin() | Exact mapping. |
SINH | sinh() | Exact mapping. |
SQRT | sqrt() | Exact mapping. |
TAN | tan() | Exact mapping. |
TANH | tanh() | Exact mapping. |
Bitwise
Alteryx uses named bitwise functions (such asBinaryAnd and BinaryOr), while SQL relies primarily on native operators (&, |, <<, >>) and a small set of helper functions. The mappings are direct, with no semantic differences.
| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
BinaryAnd | \& | No Binary keyword necessary in SQL. |
BinaryNot | bitwise_not | No Binary keyword necessary in SQL. |
BinaryOr | | | No Binary keyword necessary in SQL. |
BinaryXOR | bitwiseXOR | No Binary keyword necessary in SQL. |
ShiftLeft | << | Exact mapping. |
ShiftRight | >> | Exact mapping. |
Range and bound functions
Range and bound functions behave similarly across SQL engines, but differences arise in how arrays, ordering, and positional logic are handled.betweenworks directly; syntax just shifts to SQL form.Boundrequires an explicitcasestatement.MaxandMinare direct equivalents.MaxIDXandMinIDXin Alteryx identify the position of a value, but SQL engines typically use sorting or window functions (row_number() over (...)) to achieve the same result.
- Databricks SQL
- BigQuery
- Snowflake
| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
Between | between() | In Alteryx, Between([x], 10, 20); in SQL, x between 10 and 20. |
Bound | case when x < min then min when x > max then max else x end | Databricks SQL has no single bound function; use a case expression to clamp the value inside a range. |
Max | max() | Exact mapping. Nulls are ignored by default. |
MaxIDX | array_max() | Applies to arrays rather than datasets. To find the row containing the max value, use order by ... desc limit 1 or a window function. |
Min | min() | Exact mapping. Nulls are ignored by default. |
MinIDX | array_min() | Like array_max(), this applies to arrays. To find the row with the minimum value, use order by ... asc limit 1. |
Operators
| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
| Block comment | /**/ | Exact mapping. |
| Single-line comment | -- | // does not work in SQL. |
Boolean AND or \&\& | and | \&\& is not supported in SQL. Use AND. |
Boolean NOT or ! | ! | ! is not supported in SQL. Use NOT. |
Boolean OR or || | OR | || is not supported in SQL. Use OR. |
Equality ==, = | = | In SQL, equality is expressed as =, not ==. |
Non-equality != | != | Exact mapping. |
| Greater than, greater than or equal to, less than, less than or equal to | >, >=, <, <= | Exact mapping. |
| Addition, Subtraction, Multiplication, Division | +, -, *, / | Exact mapping. |
| Parentheses | ( ) | Exact mapping. |
value IN | in | Exact mapping. |
value NOT IN | not in | Exact mapping. |
Specialized
Specialized functions have similar conceptual mappings across SQL engines, but differences arise in indexing, null handling, and how arrays are processed. These differences are especially important when translating positional logic from Alteryx.- Indexing: Alteryx uses zero-based indices. BigQuery and Snowflake arrays are 0-based, while Databricks SQL arrays are 1-based.
- Null handling:
NULL()is a callable function in Alteryx, but a literal in SQL. - TOPNIDX: In Alteryx it finds the position of the top N value; SQL engines typically use sorting and positional access to replicate this behavior.
- Databricks SQL
- BigQuery
- Snowflake
| Alteryx Function | Equivalent SQL Function | Notes |
|---|---|---|
Coalesce | coalesce() | Alteryx evaluates left-to-right; Databricks SQL follows standard SQL semantics. |
GetVal | element_at() | In Alteryx, GetVal(list, index) retrieves the element at a 0-based index. Databricks SQL arrays are 1-based, so GetVal([x], 0) corresponds to element_at(x, 1). |
NULL | coalesce() or NULL literal | NULL is a literal in SQL, not a function. Use coalesce() to replace nulls. |
TOPNIDX | array_sort(), element_at(), and array_position() | No direct equivalent. Use array sorting plus positional lookup to approximate the behavior. For row-level ranking, use order by or window functions. |
UrlEncode | url_encode() | Exact mapping. |
String
Key differences across SQL engines:- Indexing: Databricks SQL arrays are 1-based, while BigQuery and Snowflake arrays are 0-based. Alteryx uses 0-based indexing.
- Case sensitivity: All three engines are case-sensitive by default unless you normalize with functions such as
lower()orupper(). - Regex behavior:
- Databricks: Java regex
- BigQuery: RE2
- Snowflake: POSIX-style regular expressions
- Function coverage: Some Alteryx string functions have no direct equivalent and require workarounds or UDFs.
- Substring & trimming: Similar core functions exist across engines, but syntax and edge-case behavior may differ slightly.
- Databricks SQL
- BigQuery
- Snowflake
| Alteryx | Equivalent SQL Function | Notes |
|---|---|---|
Contains | contains() | Databricks SQL is case-sensitive by default unless you apply lower() or upper(). |
CountWords | size(split(col, ' ')) | Split the string into tokens and count the resulting array elements. |
DecomposeUnicodeForMatch | No native equivalent | Requires external processing or Python UDF. |
EndsWith | col like '%pattern' | SQL uses LIKE; remember to escape special characters and use % wildcards. |
FindNth | No native equivalent | Requires workaround logic. |
FindString | locate(substring, col) | Returns the 1-based position of the substring. |
GetLeft / Left | substring(col, 1, n) | SQL substring positions start at 1. |
GetPart | element_at(split(col, ' '), n) | Databricks SQL arrays are 1-based. GetPart(col, n) → element_at(split(col, ' '), n+1) if the Alteryx index is 0-based. |
GetRight / Right | substring(col, length(col)-n+1, n) | SQL lacks a built-in right() equivalent in some contexts; emulate with substring(). |
GetWord | element_at(split(col, ' '), n) | Uses array indexing after split(). |
Length | length() | Exact mapping. |
LowerCase | lower() | Exact mapping. |
MD5_ASCII, MD5_UNICODE, MD5_UTF8 | md5() | SQL does not distinguish between encoding-specific MD5 variants. |
PadLeft | lpad(col, n, 'char') | Exact mapping. |
PadRight | rpad(col, n, 'char') | Exact mapping. |
REGEX_CountMatches | size(split(col, regex)) - 1 | No built-in counter; emulate with split() and size(). |
REGEX_Match | regexp_extract(col, regex, 0) | Returns the substring matching the regex pattern. |
REGEX_Replace, Replace, ReplaceChar, ReplaceFirst | regexp_replace(col, pattern, replacement) | Replaces all matches by default. |
ReverseString | reverse() | Exact mapping. |
StartsWith | col LIKE 'pattern%' | Case-sensitive by default. |
STRCSPN | No native equivalent | Requires custom UDF or workaround logic. |
StripQuotes | regexp_replace(col, '["'']', '') | Removes quotes using regex replacement. |
STRSPN | No native equivalent | Requires custom logic. |
Substring | substring(col, start, length) | Positions are 1-based. |
TitleCase | initcap() | Exact mapping. |
Trim | trim(col) | Exact mapping. |
TrimLeft | ltrim() | Exact mapping. |
TrimRight | rtrim() | Exact mapping. |
Uppercase | upper() | Exact mapping. |
UuidCreate | uuid() | Exact mapping. |

