Build & develop

Spark functions on this PC

Every built-in function of Spark 3.5, the Spark of Fabric runtime 1.3, with what a notebook's Spark SQL does with it on this PC. Each function's first example from Spark's documentation is run here and compared with the value Apache Spark 3.5 gives, on the DuckDB version the app ships. CI runs every check again, so this page changes when a function is fixed or breaks.

  • Runs: gives Spark's value for its example.
  • Differs: runs, but gives another value. Check results that use it in Fabric.
  • Refused: stops with a message saying why, so nothing runs with another answer.
  • Fails: stops with an error. Run the cell in Fabric.
  • Not checked: no example whose value can be compared (random values, the clock or the session, or no example).

One example per function is a first check, not proof: a function can match on its example and differ on other input. Engines lists the differences known in more detail.

Status Functions
Runs 389
Differs 0
Refused 21
Fails 0
Not checked 28
All 438

Aggregate#

Function Status Example Note
any Runs SELECT any(col) FROM VALUES (true), (false), (false) AS tab(col)
any_value Runs SELECT any_value(col) FROM VALUES (10), (5), (20) AS tab(col)
approx_count_distinct Runs SELECT approx_count_distinct(col1) FROM VALUES (1), (1), (2), (2), (3) tab(col1)
approx_percentile Runs SELECT approx_percentile(col, array(0.5, 0.4, 0.1), 100) FROM VALUES (0), (1), (2), (10) AS tab(col)
array_agg Runs SELECT array_agg(col) FROM VALUES (1), (2), (1) AS tab(col)
avg Runs SELECT avg(col) FROM VALUES (1), (2), (3) AS tab(col)
bit_and Runs SELECT bit_and(col) FROM VALUES (3), (5) AS tab(col)
bit_or Runs SELECT bit_or(col) FROM VALUES (3), (5) AS tab(col)
bit_xor Runs SELECT bit_xor(col) FROM VALUES (3), (5) AS tab(col)
bitmap_construct_agg Runs SELECT substring(hex(bitmap_construct_agg(bitmap_bit_position(col))), 0, 6) FROM VALUES (1), (2), (3) AS tab(col)
bitmap_or_agg Runs SELECT substring(hex(bitmap_or_agg(col)), 0, 6) FROM VALUES (X '10'), (X '20'), (X '40') AS tab(col)
bool_and Runs SELECT bool_and(col) FROM VALUES (true), (true), (true) AS tab(col)
bool_or Runs SELECT bool_or(col) FROM VALUES (true), (false), (false) AS tab(col)
collect_list Runs SELECT collect_list(col) FROM VALUES (1), (2), (1) AS tab(col)
collect_set Runs SELECT collect_set(col) FROM VALUES (1), (2), (1) AS tab(col)
corr Runs SELECT corr(c1, c2) FROM VALUES (3, 2), (3, 3), (6, 4) as tab(c1, c2)
count Runs SELECT count(*) FROM VALUES (NULL), (5), (5), (20) AS tab(col)
count_if Runs SELECT count_if(col % 2 = 0) FROM VALUES (NULL), (0), (1), (2), (3) AS tab(col)
count_min_sketch Refused SELECT hex(count_min_sketch(col, 0.5d, 0.5d, 1)) FROM VALUES (1), (2), (1) AS tab(col) count_min_sketch() can't run on this PC the way it runs in Fabric, so nothing ran: it builds a DataSketches or count-min sketch whose bytes this PC can't make t
covar_pop Runs SELECT covar_pop(c1, c2) FROM VALUES (1,1), (2,2), (3,3) AS tab(c1, c2)
covar_samp Runs SELECT covar_samp(c1, c2) FROM VALUES (1,1), (2,2), (3,3) AS tab(c1, c2)
every Runs SELECT every(col) FROM VALUES (true), (true), (true) AS tab(col)
first Runs SELECT first(col) FROM VALUES (10), (5), (20) AS tab(col)
first_value Runs SELECT first_value(col) FROM VALUES (10), (5), (20) AS tab(col)
grouping Runs SELECT name, grouping(name), sum(age) FROM VALUES (2, 'Alice'), (5, 'Bob') people(age, name) GROUP BY cube(name)
grouping_id Runs SELECT name, grouping_id(), sum(age), avg(height) FROM VALUES (2, 'Alice', 165), (5, 'Bob', 180) people(age, name, height) GROUP BY cube(name, height)
histogram_numeric Refused SELECT histogram_numeric(col, 5) FROM VALUES (0), (1), (2), (10) AS tab(col) histogram_numeric() can't run on this PC the way it runs in Fabric, so nothing ran: Spark's bins come from its own streaming algorithm, which this PC doesn't ha
hll_sketch_agg Refused SELECT hll_sketch_estimate(hll_sketch_agg(col, 12)) FROM VALUES (1), (1), (2), (2), (3) tab(col) hll_sketch_agg() can't run on this PC the way it runs in Fabric, so nothing ran: it builds a DataSketches or count-min sketch whose bytes this PC can't make the
hll_union_agg Refused SELECT hll_sketch_estimate(hll_union_agg(sketch, true)) FROM (SELECT hll_sketch_agg(col) as sketch FROM VALUES (1) tab(col) UNION ALL SELECT hll_sketch_agg(col, 20) as sketch FROM VALUES (1) tab(col)) hll_sketch_agg() can't run on this PC the way it runs in Fabric, so nothing ran: it builds a DataSketches or count-min sketch whose bytes this PC can't make the
kurtosis Runs SELECT kurtosis(col) FROM VALUES (-10), (-20), (100), (1000) AS tab(col)
last Runs SELECT last(col) FROM VALUES (10), (5), (20) AS tab(col)
last_value Runs SELECT last_value(col) FROM VALUES (10), (5), (20) AS tab(col)
max Runs SELECT max(col) FROM VALUES (10), (50), (20) AS tab(col)
max_by Runs SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 20) AS tab(x, y)
mean Runs SELECT mean(col) FROM VALUES (1), (2), (3) AS tab(col)
median Runs SELECT median(col) FROM VALUES (0), (10) AS tab(col)
min Runs SELECT min(col) FROM VALUES (10), (-1), (20) AS tab(col)
min_by Runs SELECT min_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 20) AS tab(x, y)
mode Runs SELECT mode(col) FROM VALUES (0), (10), (10) AS tab(col)
percentile Runs SELECT percentile(col, 0.3) FROM VALUES (0), (10) AS tab(col)
percentile_approx Runs SELECT percentile_approx(col, array(0.5, 0.4, 0.1), 100) FROM VALUES (0), (1), (2), (10) AS tab(col)
regr_avgx Runs SELECT regr_avgx(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x)
regr_avgy Runs SELECT regr_avgy(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x)
regr_count Runs SELECT regr_count(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x)
regr_intercept Runs SELECT regr_intercept(y, x) FROM VALUES (1,1), (2,2), (3,3) AS tab(y, x)
regr_r2 Runs SELECT regr_r2(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x)
regr_slope Runs SELECT regr_slope(y, x) FROM VALUES (1,1), (2,2), (3,3) AS tab(y, x)
regr_sxx Runs SELECT regr_sxx(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x)
regr_sxy Runs SELECT regr_sxy(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x)
regr_syy Runs SELECT regr_syy(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x)
skewness Runs SELECT skewness(col) FROM VALUES (-10), (-20), (100), (1000) AS tab(col)
some Runs SELECT some(col) FROM VALUES (true), (false), (false) AS tab(col)
std Runs SELECT std(col) FROM VALUES (1), (2), (3) AS tab(col)
stddev Runs SELECT stddev(col) FROM VALUES (1), (2), (3) AS tab(col)
stddev_pop Runs SELECT stddev_pop(col) FROM VALUES (1), (2), (3) AS tab(col)
stddev_samp Runs SELECT stddev_samp(col) FROM VALUES (1), (2), (3) AS tab(col)
sum Runs SELECT sum(col) FROM VALUES (5), (10), (15) AS tab(col)
try_avg Runs SELECT try_avg(col) FROM VALUES (1), (2), (3) AS tab(col)
try_sum Runs SELECT try_sum(col) FROM VALUES (5), (10), (15) AS tab(col)
var_pop Runs SELECT var_pop(col) FROM VALUES (1), (2), (3) AS tab(col)
var_samp Runs SELECT var_samp(col) FROM VALUES (1), (2), (3) AS tab(col)
variance Runs SELECT variance(col) FROM VALUES (1), (2), (3) AS tab(col)

Array#

Function Status Example Note
array Runs SELECT array(1, 2, 3)
array_append Runs SELECT array_append(array('b', 'd', 'c', 'a'), 'd')
array_compact Runs SELECT array_compact(array(1, 2, 3, null))
array_contains Runs SELECT array_contains(array(1, 2, 3), 2)
array_distinct Runs SELECT array_distinct(array(1, 2, 3, null, 3))
array_except Runs SELECT array_except(array(1, 2, 3), array(1, 3, 5))
array_insert Runs SELECT array_insert(array(1, 2, 3, 4), 5, 5)
array_intersect Runs SELECT array_intersect(array(1, 2, 3), array(1, 3, 5))
array_join Runs SELECT array_join(array('hello', 'world'), ' ')
array_max Runs SELECT array_max(array(1, 20, null, 3))
array_min Runs SELECT array_min(array(1, 20, null, 3))
array_position Runs SELECT array_position(array(312, 773, 708, 708), 708)
array_prepend Runs SELECT array_prepend(array('b', 'd', 'c', 'a'), 'd')
array_remove Runs SELECT array_remove(array(1, 2, 3, null, 3), 3)
array_repeat Runs SELECT array_repeat('123', 2)
array_union Runs SELECT array_union(array(1, 2, 3), array(1, 3, 5))
arrays_overlap Runs SELECT arrays_overlap(array(1, 2, 3), array(3, 4, 5))
arrays_zip Runs SELECT arrays_zip(array(1, 2, 3), array(2, 3, 4))
flatten Runs SELECT flatten(array(array(1, 2), array(3, 4)))
get Runs SELECT get(array(1, 2, 3), 0)
sequence Runs SELECT sequence(1, 5)
shuffle Not checked SELECT shuffle(array(1, 20, 3, 5))
slice Runs SELECT slice(array(1, 2, 3, 4), 2, 2)
sort_array Runs SELECT sort_array(array('b', 'd', null, 'c', 'a'), true)

Bitwise#

Function Status Example Note
& Runs SELECT 3 & 5
^ Runs SELECT 3 ^ 5
bit_count Runs SELECT bit_count(0)
bit_get Runs SELECT bit_get(11, 0)
getbit Runs SELECT getbit(11, 0)
shiftright Runs SELECT shiftright(4, 1)
shiftrightunsigned Runs SELECT shiftrightunsigned(4, 1)
| Runs SELECT 3 | 5
~ Runs SELECT ~ 0

Collection#

Function Status Example Note
array_size Runs SELECT array_size(array('b', 'd', 'c', 'a'))
cardinality Runs SELECT cardinality(array('b', 'd', 'c', 'a'))
concat Runs SELECT concat('Spark', 'SQL')
reverse Runs SELECT reverse('Spark SQL')
size Runs SELECT size(array('b', 'd', 'c', 'a'))

Conditional#

Function Status Example Note
coalesce Runs SELECT coalesce(NULL, 1, NULL)
if Runs SELECT if(1 < 2, 'a', 'b')
ifnull Runs SELECT ifnull(NULL, array('2'))
nanvl Runs SELECT nanvl(cast('NaN' as double), 123)
nullif Runs SELECT nullif(2, 2)
nvl Runs SELECT nvl(NULL, array('2'))
nvl2 Runs SELECT nvl2(NULL, 2, 1)
when Runs SELECT CASE WHEN 1 > 0 THEN 1 WHEN 2 > 0 THEN 2.0 ELSE 1.2 END

Conversion#

Function Status Example Note
bigint Runs SELECT bigint('12'), bigint(3.9), bigint(-3.9)
binary Runs SELECT binary('Spark')
boolean Runs SELECT boolean('true'), boolean(0), boolean('no')
cast Runs SELECT cast('10' as int)
date Runs SELECT date('2026-01-31'), date(TIMESTAMP '2026-01-31 23:59:59')
decimal Runs SELECT decimal('12.345'), decimal(7)
double Runs SELECT double('1.5'), double(2)
float Runs SELECT float('1.5'), float(2)
int Runs SELECT int('12'), int(3.9), int(-3.9)
smallint Runs SELECT smallint('12'), smallint(3.9)
string Runs SELECT string(12), string(1.50), string(true), string(DATE '2026-01-31')
timestamp Runs SELECT timestamp('2026-01-31 10:30:00'), timestamp(DATE '2026-01-31')
tinyint Runs SELECT tinyint('12'), tinyint(3.9)

CSV#

Function Status Example Note
from_csv Runs SELECT from_csv('1, 0.8', 'a INT, b DOUBLE')
schema_of_csv Refused SELECT schema_of_csv('1,abc') schema_of_csv() can't run on this PC the way it runs in Fabric, so nothing ran: this PC doesn't infer a CSV schema from one line the way Spark does. Run the cel
to_csv Runs SELECT to_csv(named_struct('a', 1, 'b', 2))

Date and time#

Function Status Example Note
add_months Runs SELECT add_months('2016-08-31', 1)
convert_timezone Runs SELECT convert_timezone('Europe/Brussels', 'America/Los_Angeles', timestamp_ntz'2021-12-06 00:00:00')
curdate Not checked SELECT curdate()
current_date Not checked SELECT current_date()
current_timestamp Not checked SELECT current_timestamp()
current_timezone Not checked SELECT current_timezone()
date_add Runs SELECT date_add('2016-07-30', 1)
date_diff Runs SELECT date_diff('2009-07-31', '2009-07-30')
date_format Runs SELECT date_format('2016-04-08', 'y')
date_from_unix_date Runs SELECT date_from_unix_date(1)
date_part Runs SELECT date_part('YEAR', TIMESTAMP '2019-08-12 01:00:00.123456')
date_sub Runs SELECT date_sub('2016-07-30', 1)
date_trunc Runs SELECT date_trunc('YEAR', '2015-03-05T09:32:05.359')
dateadd Runs SELECT dateadd('2016-07-30', 1)
datediff Runs SELECT datediff('2009-07-31', '2009-07-30')
datepart Runs SELECT datepart('YEAR', TIMESTAMP '2019-08-12 01:00:00.123456')
day Runs SELECT day('2009-07-30')
dayofmonth Runs SELECT dayofmonth('2009-07-30')
dayofweek Runs SELECT dayofweek('2009-07-30')
dayofyear Runs SELECT dayofyear('2016-04-09')
extract Runs SELECT extract(YEAR FROM TIMESTAMP '2019-08-12 01:00:00.123456')
from_unixtime Runs SELECT from_unixtime(0, 'yyyy-MM-dd HH:mm:ss')
from_utc_timestamp Runs SELECT from_utc_timestamp('2016-08-31', 'Asia/Seoul')
hour Runs SELECT hour('2009-07-30 12:58:59')
last_day Runs SELECT last_day('2009-01-12')
localtimestamp Not checked SELECT localtimestamp()
make_date Runs SELECT make_date(2013, 7, 15)
make_dt_interval Runs SELECT make_dt_interval(1, 12, 30, 01.001001)
make_interval Runs SELECT TIMESTAMP '2026-01-31 00:00:00' + make_interval(1, 2, 0, 3, 4, 5, 6.5)
make_timestamp Runs SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887)
make_timestamp_ltz Runs SELECT make_timestamp_ltz(2014, 12, 28, 6, 30, 45.887)
make_timestamp_ntz Runs SELECT make_timestamp_ntz(2014, 12, 28, 6, 30, 45.887)
make_ym_interval Refused SELECT make_ym_interval(1, 2) make_ym_interval() can't run on this PC the way it runs in Fabric, so nothing ran: this PC has no year-month interval type. Run the cell in Fabric.
minute Runs SELECT minute('2009-07-30 12:58:59')
month Runs SELECT month('2016-07-30')
months_between Runs SELECT months_between('1997-02-28 10:30:00', '1996-10-30')
next_day Runs SELECT next_day('2015-01-14', 'TU')
now Not checked SELECT now()
quarter Runs SELECT quarter('2016-08-31')
second Runs SELECT second('2009-07-30 12:58:59')
session_window Refused SELECT a, session_window.start, session_window.end, count(*) as cnt FROM VALUES ('A1', '2021-01-01 00:00:00'), ('A1', '2021-01-01 00:04:30'), ('A1', '2021-01-01 00:10:00'), ('A2', '2021-01-01 00:01:00') AS tab(a, b) GROUP by a, session_window(b, '5 minutes') ORDER BY a, start session_window() can't run on this PC the way it runs in Fabric, so nothing ran: session windows run in Fabric only. Run the cell in Fabric.
timestamp_micros Runs SELECT timestamp_micros(1230219000123123)
timestamp_millis Runs SELECT timestamp_millis(1230219000123)
timestamp_seconds Runs SELECT timestamp_seconds(1230219000)
to_date Runs SELECT to_date('2009-07-30 04:17:52')
to_timestamp Runs SELECT to_timestamp('2016-12-31 00:12:00')
to_timestamp_ltz Runs SELECT to_timestamp_ltz('2016-12-31 00:12:00')
to_timestamp_ntz Runs SELECT to_timestamp_ntz('2016-12-31 00:12:00')
to_unix_timestamp Runs SELECT to_unix_timestamp('2016-04-08', 'yyyy-MM-dd')
to_utc_timestamp Runs SELECT to_utc_timestamp('2016-08-31', 'Asia/Seoul')
trunc Runs SELECT trunc('2019-08-04', 'week')
try_to_timestamp Runs SELECT try_to_timestamp('2016-12-31 00:12:00')
unix_date Runs SELECT unix_date(DATE("1970-01-02"))
unix_micros Runs SELECT unix_micros(TIMESTAMP('1970-01-01 00:00:01Z'))
unix_millis Runs SELECT unix_millis(TIMESTAMP('1970-01-01 00:00:01Z'))
unix_seconds Runs SELECT unix_seconds(TIMESTAMP('1970-01-01 00:00:01Z'))
unix_timestamp Not checked SELECT unix_timestamp()
weekday Runs SELECT weekday('2009-07-30')
weekofyear Runs SELECT weekofyear('2008-02-20')
window Runs SELECT a, window.start, window.end, count(*) as cnt FROM VALUES ('A1', '2021-01-01 00:00:00'), ('A1', '2021-01-01 00:04:30'), ('A1', '2021-01-01 00:06:00'), ('A2', '2021-01-01 00:01:00') AS tab(a, b) GROUP by a, window(b, '5 minutes') ORDER BY a, start
window_time Runs SELECT a, window.start as start, window.end as end, window_time(window), cnt FROM (SELECT a, window, count(*) as cnt FROM VALUES ('A1', '2021-01-01 00:00:00'), ('A1', '2021-01-01 00:04:30'), ('A1', '2021-01-01 00:06:00'), ('A2', '2021-01-01 00:01:00') AS tab(a, b) GROUP by a, window(b, '5 minutes') ORDER BY a, window.start)
year Runs SELECT year('2016-07-30')

Generator#

Function Status Example Note
explode Runs SELECT explode(array(10, 20))
explode_outer Runs SELECT explode_outer(array(10, 20))
inline Runs SELECT inline(array(struct(1, 'a'), struct(2, 'b')))
inline_outer Runs SELECT inline_outer(array(struct(1, 'a'), struct(2, 'b')))
posexplode Runs SELECT posexplode(array(10,20))
posexplode_outer Runs SELECT posexplode_outer(array(10,20))
stack Runs SELECT stack(2, 1, 2, 3)

Hash#

Function Status Example Note
crc32 Runs SELECT crc32('Spark')
hash Runs SELECT hash('Spark', array(123), 2)
md5 Runs SELECT md5('Spark')
sha Runs SELECT sha('Spark')
sha1 Runs SELECT sha1('Spark')
sha2 Runs SELECT sha2('Spark', 256)
xxhash64 Runs SELECT xxhash64('Spark', array(123), 2)

JSON#

Function Status Example Note
from_json Runs SELECT from_json('{"a":1, "b":0.8}', 'a INT, b DOUBLE')
get_json_object Runs SELECT get_json_object('{"a":"b"}', '$.a')
json_array_length Runs SELECT json_array_length('[1,2,3,4]')
json_object_keys Runs SELECT json_object_keys('{}')
json_tuple Runs SELECT json_tuple('{"a":1, "b":2}', 'a', 'b')
schema_of_json Runs SELECT schema_of_json('[{"col":0}]')
to_json Runs SELECT to_json(named_struct('a', 1, 'b', 2))

Lambda#

Function Status Example Note
aggregate Runs SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x)
array_sort Runs SELECT array_sort(array(5, 6, 1), (left, right) -> case when left < right then -1 when left > right then 1 else 0 end)
exists Runs SELECT exists(array(1, 2, 3), x -> x % 2 == 0)
filter Runs SELECT filter(array(1, 2, 3), x -> x % 2 == 1)
forall Runs SELECT forall(array(1, 2, 3), x -> x % 2 == 0)
map_filter Runs SELECT map_filter(map(1, 0, 2, 2, 3, -1), (k, v) -> k > v)
map_zip_with Runs SELECT map_zip_with(map(1, 'a', 2, 'b'), map(1, 'x', 2, 'y'), (k, v1, v2) -> concat(v1, v2))
reduce Runs SELECT reduce(array(1, 2, 3), 0, (acc, x) -> acc + x)
transform Runs SELECT transform(array(1, 2, 3), x -> x + 1)
transform_keys Runs SELECT transform_keys(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + 1)
transform_values Runs SELECT transform_values(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> v + 1)
zip_with Runs SELECT zip_with(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x))

Map#

Function Status Example Note
element_at Runs SELECT element_at(array(1, 2, 3), 2)
map Runs SELECT map(1.0, '2', 3.0, '4')
map_concat Runs SELECT map_concat(map(1, 'a', 2, 'b'), map(3, 'c'))
map_contains_key Runs SELECT map_contains_key(map(1, 'a', 2, 'b'), 1)
map_entries Runs SELECT map_entries(map(1, 'a', 2, 'b'))
map_from_arrays Runs SELECT map_from_arrays(array(1.0, 3.0), array('2', '4'))
map_from_entries Runs SELECT map_from_entries(array(struct(1, 'a'), struct(2, 'b')))
map_keys Runs SELECT map_keys(map(1, 'a', 2, 'b'))
map_values Runs SELECT map_values(map(1, 'a', 2, 'b'))
str_to_map Runs SELECT str_to_map('a:1,b:2,c:3', ',', ':')
try_element_at Runs SELECT try_element_at(array(1, 2, 3), 2)

Math#

Function Status Example Note
% Runs SELECT 2 % 1.8
* Runs SELECT 2 * 3
+ Runs SELECT 1 + 2
- Runs SELECT 2 - 1
/ Runs SELECT 3 / 2
abs Runs SELECT abs(-1)
acos Runs SELECT acos(1)
acosh Runs SELECT acosh(1)
asin Runs SELECT asin(0)
asinh Runs SELECT asinh(0)
atan Runs SELECT atan(0)
atan2 Runs SELECT atan2(0, 0)
atanh Runs SELECT atanh(0)
bin Runs SELECT bin(13)
bround Runs SELECT bround(2.5, 0)
cbrt Runs SELECT cbrt(27.0)
ceil Runs SELECT ceil(-0.1)
ceiling Runs SELECT ceiling(-0.1)
conv Runs SELECT conv('100', 2, 10)
cos Runs SELECT cos(0)
cosh Runs SELECT cosh(0)
cot Runs SELECT cot(1)
csc Runs SELECT csc(1)
degrees Runs SELECT degrees(3.141592653589793)
div Runs SELECT 3 div 2
e Runs SELECT e()
exp Runs SELECT exp(0)
expm1 Runs SELECT expm1(0)
factorial Runs SELECT factorial(5)
floor Runs SELECT floor(-0.1)
greatest Runs SELECT greatest(10, 9, 2, 4, 3)
hex Runs SELECT hex(17)
hypot Runs SELECT hypot(3, 4)
least Runs SELECT least(10, 9, 2, 4, 3)
ln Runs SELECT ln(1)
log Runs SELECT log(10, 100)
log10 Runs SELECT log10(10)
log1p Runs SELECT log1p(0)
log2 Runs SELECT log2(2)
mod Runs SELECT 2 % 1.8
negative Runs SELECT negative(1)
pi Runs SELECT pi()
pmod Runs SELECT pmod(10, 3)
positive Runs SELECT positive(1)
pow Runs SELECT pow(2, 3)
power Runs SELECT power(2, 3)
radians Runs SELECT radians(180)
rand Not checked SELECT rand()
randn Not checked SELECT randn()
random Not checked SELECT random()
rint Runs SELECT rint(12.3456)
round Runs SELECT round(2.5, 0)
sec Runs SELECT sec(0)
shiftleft Runs SELECT shiftleft(2, 1)
sign Runs SELECT sign(40)
signum Runs SELECT signum(40)
sin Runs SELECT sin(0)
sinh Runs SELECT sinh(0)
sqrt Runs SELECT sqrt(4)
tan Runs SELECT tan(0)
tanh Runs SELECT tanh(0)
try_add Runs SELECT try_add(1, 2)
try_divide Runs SELECT try_divide(3, 2)
try_multiply Runs SELECT try_multiply(2, 3)
try_subtract Runs SELECT try_subtract(2, 1)
unhex Runs SELECT decode(unhex('537061726B2053514C'), 'UTF-8')
width_bucket Runs SELECT width_bucket(5.3, 0.2, 10.6, 5)

Miscellaneous#

Function Status Example Note
aes_decrypt Refused SELECT aes_decrypt(unhex('83F16B2AA704794132802D248E6BFD4E380078182D1544813898AC97E709B28A94'), '0000111122223333') aes_decrypt() can't run on this PC the way it runs in Fabric, so nothing ran: AES isn't available in the engine on this PC. Run the cell in Fabric.
aes_encrypt Not checked SELECT hex(aes_encrypt('Spark', '0000111122223333'))
assert_true Runs SELECT assert_true(0 < 1)
bitmap_bit_position Runs SELECT bitmap_bit_position(1)
bitmap_bucket_number Runs SELECT bitmap_bucket_number(123)
bitmap_count Runs SELECT bitmap_count(X '1010')
current_catalog Not checked SELECT current_catalog()
current_database Not checked SELECT current_database()
current_schema Not checked SELECT current_schema()
current_user Not checked SELECT current_user()
equal_null Runs SELECT equal_null(3, 3)
hll_sketch_estimate Refused SELECT hll_sketch_estimate(hll_sketch_agg(col)) FROM VALUES (1), (1), (2), (2), (3) tab(col) hll_sketch_agg() can't run on this PC the way it runs in Fabric, so nothing ran: it builds a DataSketches or count-min sketch whose bytes this PC can't make the
hll_union Refused SELECT hll_sketch_estimate(hll_union(hll_sketch_agg(col1), hll_sketch_agg(col2))) FROM VALUES (1, 4), (1, 4), (2, 5), (2, 5), (3, 6) tab(col1, col2) hll_sketch_agg() can't run on this PC the way it runs in Fabric, so nothing ran: it builds a DataSketches or count-min sketch whose bytes this PC can't make the
input_file_block_length Not checked SELECT input_file_block_length()
input_file_block_start Not checked SELECT input_file_block_start()
input_file_name Not checked SELECT input_file_name()
java_method Not checked SELECT java_method('java.util.UUID', 'randomUUID')
monotonically_increasing_id Not checked SELECT monotonically_increasing_id()
raise_error Not checked SELECT raise_error('custom error message')
reflect Not checked SELECT reflect('java.util.UUID', 'randomUUID')
spark_partition_id Not checked SELECT spark_partition_id()
try_aes_decrypt Refused SELECT try_aes_decrypt(unhex('6E7CA17BBB468D3084B5744BCA729FB7B2B7BCB8E4472847D02670489D95FA97DBBA7D3210'), '0000111122223333', 'GCM') try_aes_decrypt() can't run on this PC the way it runs in Fabric, so nothing ran: AES isn't available in the engine on this PC. Run the cell in Fabric.
typeof Runs SELECT typeof(1)
user Not checked SELECT user()
uuid Not checked SELECT uuid()
version Not checked SELECT version()

Operators and other#

Function Status Example Note
!= Runs SELECT 1 != 2, 'a' != 'a', NULL != 1
<> Runs SELECT 1 <> 2, 'a' <> 'a', NULL <> 1
between Runs SELECT 2 BETWEEN 1 AND 3, 4 BETWEEN 1 AND 3, 'b' BETWEEN 'a' AND 'c'
case Runs SELECT CASE WHEN 1 > 0 THEN 'a' ELSE 'b' END, CASE 2 WHEN 1 THEN 'x' END
range Runs SELECT * FROM range(1, 7, 2)
sql_keywords Not checked
|| Runs SELECT 'Spark' || 'SQL', 'a' || NULL

Predicate#

Function Status Example Note
! Runs SELECT ! true
< Runs SELECT 1 < 2
<= Runs SELECT 2 <= 2
<=> Runs SELECT 2 <=> 2
= Runs SELECT 2 = 2
== Runs SELECT 2 == 2
> Runs SELECT 2 > 1
>= Runs SELECT 2 >= 1
and Runs SELECT true and true
ilike Runs SELECT ilike('Spark', '_Park')
in Runs SELECT 1 in(1, 2, 3)
isnan Runs SELECT isnan(cast('NaN' as double))
isnotnull Runs SELECT isnotnull(1)
isnull Runs SELECT isnull(1)
like Runs SELECT like('Spark', '_park')
not Runs SELECT not true
or Runs SELECT true or false
regexp Runs SELECT regexp('Steven', 'Ste(v|ph)en'), regexp('Stefan', 'Ste(v|ph)en')
regexp_like Runs SELECT regexp_like('Steven', 'Ste(v|ph)en'), regexp_like('Stefan', 'Ste(v|ph)en')
rlike Runs SELECT rlike('Steven', 'Ste(v|ph)en'), rlike('Stefan', 'Ste(v|ph)en')

String#

Function Status Example Note
ascii Runs SELECT ascii('222')
base64 Runs SELECT base64('Spark SQL')
bit_length Runs SELECT bit_length('Spark SQL')
btrim Runs SELECT btrim(' SparkSQL ')
char Runs SELECT char(65)
char_length Runs SELECT char_length('Spark SQL ')
character_length Runs SELECT character_length('Spark SQL ')
chr Runs SELECT chr(65)
concat_ws Runs SELECT concat_ws(' ', 'Spark', 'SQL')
contains Runs SELECT contains('Spark SQL', 'Spark')
decode Runs SELECT decode(encode('abc', 'utf-8'), 'utf-8')
elt Runs SELECT elt(1, 'scala', 'java')
encode Runs SELECT encode('abc', 'utf-8')
endswith Runs SELECT endswith('Spark SQL', 'SQL')
find_in_set Runs SELECT find_in_set('ab','abc,b,ab,c,def')
format_number Runs SELECT format_number(12332.123456, 4)
format_string Runs SELECT format_string("Hello World %d %s", 100, "days")
initcap Runs SELECT initcap('sPark sql')
instr Runs SELECT instr('SparkSQL', 'SQL')
lcase Runs SELECT lcase('SparkSql')
left Runs SELECT left('Spark SQL', 3)
len Runs SELECT len('Spark SQL ')
length Runs SELECT length('Spark SQL ')
levenshtein Runs SELECT levenshtein('kitten', 'sitting')
locate Runs SELECT locate('bar', 'foobarbar')
lower Runs SELECT lower('SparkSql')
lpad Runs SELECT lpad('hi', 5, '??')
ltrim Runs SELECT ltrim(' SparkSQL ')
luhn_check Runs SELECT luhn_check('8112189876')
mask Runs SELECT mask('abcd-EFGH-8765-4321')
octet_length Runs SELECT octet_length('Spark SQL')
overlay Runs SELECT overlay('Spark SQL' PLACING '_' FROM 6)
position Runs SELECT position('bar', 'foobarbar')
printf Runs SELECT printf("Hello World %d %s", 100, "days")
regexp_count Runs SELECT regexp_count('Steven Jones and Stephen Smith are the best players', 'Ste(v|ph)en')
regexp_extract Runs SELECT regexp_extract('100-200', '(\\d+)-(\\d+)', 1)
regexp_extract_all Runs SELECT regexp_extract_all('100-200, 300-400', '(\\d+)-(\\d+)', 1)
regexp_instr Runs SELECT regexp_instr('user@spark.apache.org', '@[^.]*')
regexp_replace Runs SELECT regexp_replace('100-200', '(\\d+)', 'num')
regexp_substr Runs SELECT regexp_substr('Steven Jones and Stephen Smith are the best players', 'Ste(v|ph)en')
repeat Runs SELECT repeat('123', 2)
replace Runs SELECT replace('ABCabc', 'abc', 'DEF')
right Runs SELECT right('Spark SQL', 3)
rpad Runs SELECT rpad('hi', 5, '??')
rtrim Runs SELECT rtrim(' SparkSQL ')
sentences Refused SELECT sentences('Hi there! Good morning.') sentences() can't run on this PC the way it runs in Fabric, so nothing ran: it splits text by Java's locale rules, which this PC doesn't have. Run the cell in F
soundex Runs SELECT soundex('Miller')
space Runs SELECT concat(space(2), '1')
split Runs SELECT split('oneAtwoBthreeC', '[ABC]')
split_part Runs SELECT split_part('11.12.13', '.', 3)
startswith Runs SELECT startswith('Spark SQL', 'Spark')
substr Runs SELECT substr('Spark SQL', 5)
substring Runs SELECT substring('Spark SQL', 5)
substring_index Runs SELECT substring_index('www.apache.org', '.', 2)
to_binary Runs SELECT to_binary('abc', 'utf-8')
to_char Runs SELECT to_char(454, '999')
to_number Runs SELECT to_number('454', '999')
to_varchar Runs SELECT to_varchar(454, '999')
translate Runs SELECT translate('AaBbCc', 'abc', '123')
trim Runs SELECT trim(' SparkSQL ')
try_to_binary Runs SELECT try_to_binary('abc', 'utf-8')
try_to_number Runs SELECT try_to_number('454', '999')
ucase Runs SELECT ucase('SparkSql')
unbase64 Runs SELECT unbase64('U3BhcmsgU1FM')
upper Runs SELECT upper('SparkSql')

Struct#

Function Status Example Note
named_struct Runs SELECT named_struct("a", 1, "b", 2, "c", 3)
struct Runs SELECT struct(1, 2, 3)

URL#

Function Status Example Note
parse_url Runs SELECT parse_url('http://spark.apache.org/path?query=1', 'HOST')
url_decode Runs SELECT url_decode('https%3A%2F%2Fspark.apache.org')
url_encode Runs SELECT url_encode('https://spark.apache.org')

Window#

Function Status Example Note
cume_dist Runs SELECT a, b, cume_dist() OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
dense_rank Runs SELECT a, b, dense_rank(b) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
lag Runs SELECT a, b, lag(b) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
lead Runs SELECT a, b, lead(b) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
nth_value Runs SELECT a, b, nth_value(b, 2) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
ntile Runs SELECT a, b, ntile(2) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
percent_rank Runs SELECT a, b, percent_rank(b) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
rank Runs SELECT a, b, rank(b) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)
row_number Runs SELECT a, b, row_number() OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b)

XML#

Function Status Example Note
xpath Refused SELECT xpath('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>','a/b/text()') xpath() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_boolean Refused SELECT xpath_boolean('<a><b>1</b></a>','a/b') xpath_boolean() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_double Refused SELECT xpath_double('<a><b>1</b><b>2</b></a>', 'sum(a/b)') xpath_double() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_float Refused SELECT xpath_float('<a><b>1</b><b>2</b></a>', 'sum(a/b)') xpath_float() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_int Refused SELECT xpath_int('<a><b>1</b><b>2</b></a>', 'sum(a/b)') xpath_int() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_long Refused SELECT xpath_long('<a><b>1</b><b>2</b></a>', 'sum(a/b)') xpath_long() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_number Refused SELECT xpath_number('<a><b>1</b><b>2</b></a>', 'sum(a/b)') xpath_number() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_short Refused SELECT xpath_short('<a><b>1</b><b>2</b></a>', 'sum(a/b)') xpath_short() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.
xpath_string Refused SELECT xpath_string('<a><b>b</b><c>cc</c></a>','a/c') xpath_string() can't run on this PC the way it runs in Fabric, so nothing ran: XPath isn't available in the engine on this PC. Run the cell in Fabric.

Need a hand?

Find a fix in troubleshooting, or share a reproducible issue with the community.

Get support ↗Improve this guide on GitHub ↗
Development documentation snapshot: cbf1c74e441de6cb982e7b463591fc6f1a3d2c6b · View source on GitHub ↗

Search documentation

Start typing to search all 115 guides.

Search runs in your browser esc to close