-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flink): implement UDF support for the backend (#8142)
- Loading branch information
Showing
8 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
FROM flink:1.18.1 | ||
|
||
# ibis-flink requires PyFlink dependency | ||
RUN wget -nv -P $FLINK_HOME/lib/ https://repo1.maven.org/maven2/org/apache/flink/flink-python/1.18.1/flink-python-1.18.1.jar | ||
|
||
# install python3 and pip3 | ||
RUN apt-get update -y && \ | ||
apt-get install -y python3 python3-pip python3-dev && rm -rf /var/lib/apt/lists/* | ||
RUN ln -s /usr/bin/python3 /usr/bin/python | ||
|
||
# install PyFlink | ||
RUN pip3 install apache-flink==1.18.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import annotations | ||
|
||
from ibis import udf | ||
|
||
|
||
def test_builtin_scalar_udf(con): | ||
@udf.scalar.builtin | ||
def parse_url(string1: str, string2: str) -> str: | ||
... | ||
|
||
expr = parse_url("http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1", "HOST") | ||
result = con.execute(expr) | ||
assert result == "facebook.com" | ||
|
||
|
||
def test_builtin_agg_udf(con): | ||
@udf.agg.builtin | ||
def json_arrayagg(a) -> str: | ||
"""Glom together some JSON.""" | ||
|
||
ft = con.tables.functional_alltypes[:5] | ||
expr = json_arrayagg(ft.string_col) | ||
result = expr.execute() | ||
expected = '["0","1","2","3","4"]' | ||
assert result == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters