summaryrefslogtreecommitdiffstats
path: root/yt/yql/tests/sql/suites/optimizers/yql-14581_fuseflatmaps_with_external_lambda.yql
blob: 1302d6dde048f91f5f6f090f3d86134afd199896 (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
28
/* postgres can not */
USE plato;

$improve_low = ($val) -> {
    RETURN CAST($val AS Utf8);
};

$names_intersection = ($org_names, $db_names) -> {
    RETURN ListLength(
        ListFlatten(
            ListMap(
                $org_names,
                ($org_name) -> {
                    RETURN ListFilter(
                        $db_names,
                        ($db_name) -> {
                            $org_name = $improve_low($org_name);
                            $db_name = $improve_low($db_name);
                            RETURN Unicode::LevensteinDistance($org_name, $db_name) < 0.2 * Unicode::GetLength($org_name);
                        }
                    );
                }
            )
        )
    ) > 0;
};

select $names_intersection(['1', '2'], ['nets'])