Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): expose the ability to refer to existing functions not defined in ibis APIs #7119

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented Sep 10, 2023

This PR exposes our already-existing opaque UDFs (renamed to builtin here), and adds tests for the API. Draft mode until I add tests for more backends.

@cpcloud cpcloud added this to the 7.0 milestone Sep 10, 2023
@cpcloud cpcloud added feature Features or general enhancements ux User experience related issues labels Sep 10, 2023
@cpcloud cpcloud changed the title builtin udf feat(api): expose the ability to refer to existing functions not defined in ibis Sep 10, 2023
@cpcloud cpcloud force-pushed the builtin-udf branch 2 times, most recently from 91cb562 to 54398d8 Compare September 10, 2023 11:53
@cpcloud cpcloud changed the title feat(api): expose the ability to refer to existing functions not defined in ibis feat(api): expose the ability to refer to existing functions not defined in ibis APIs Sep 10, 2023
@cpcloud cpcloud force-pushed the builtin-udf branch 4 times, most recently from a670a11 to 9ec2623 Compare September 11, 2023 12:05
@cpcloud cpcloud marked this pull request as ready for review September 11, 2023 12:06
@cpcloud cpcloud force-pushed the builtin-udf branch 4 times, most recently from 81de075 to a4a02cd Compare September 11, 2023 14:39
Copy link
Member

@jcrist jcrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited to see this feature. Just a quick surface-level review for now.

ibis/expr/operations/udf.py Show resolved Hide resolved
docs/how-to/extending/builtin.qmd Show resolved Hide resolved
docs/how-to/extending/builtin.qmd Outdated Show resolved Hide resolved
@cpcloud cpcloud force-pushed the builtin-udf branch 2 times, most recently from 5e4c8ac to 68c97d9 Compare September 11, 2023 18:25
@cpcloud cpcloud requested a review from jcrist September 11, 2023 18:25
@cpcloud cpcloud added the udf Issues related to user-defined functions label Sep 11, 2023


@udf.scalar.builtin(name="arrayJaccardIndex")
def array_jaccard_index(a: dt.Array[dt.int64], b: dt.Array[dt.int64]) -> float:
Copy link
Member

@kszucs kszucs Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datatype types should be the preferred spelling: dt.Array[dt.Int64], at least static type checkers will complain about the instances.

from ibis import udf

@udf.scalar.builtin
def mismatches(left: str, right: str) -> int:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty nice!

Copy link
Member

@kszucs kszucs Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a note about annotations being optional? There is a separate PR for that.

Copy link
Member

@kszucs kszucs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This will be pretty useful!

@NickCrews
Copy link
Contributor

This is super useful! Nice walkthrough writeup, that really is going to mean this gets used more. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements udf Issues related to user-defined functions ux User experience related issues
Projects
None yet
4 participants