aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/udf/udaf_short.sql
blob: 9072ffb8cca26a4af235688c47a0b5b88c7dcfc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* postgres can not */
/* syntax version 1 */
$script = @@
def create(item):
    return item

def add(state, item):
    return state + item 

def merge(state_a, state_b):
    return state_a + state_b 
@@;

$create = Python3::create(Callable<(Int64)->Int64>, $script);
$add = Python3::add(Callable<(Int64,Int64)->Int64>, $script);
$merge = Python3::merge(Callable<(Int64,Int64)->Int64>, $script);

SELECT UDAF(
    item,
    $create,
    $add,
    $merge
) FROM (
    SELECT
        CAST(LENGTH(value) AS Int64) AS item
    FROM plato.Input
);