Skip to content

daft.functions.ilike#

ilike #

ilike(expr: Expression, pattern: str | Expression) -> Expression

Checks whether each string matches the given SQL ILIKE pattern, case insensitive.

Returns:

Name Type Description
Expression Expression

a Boolean expression indicating whether each value matches the provided pattern

Note

Use % as a multiple-character wildcard or _ as a single-character wildcard.

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import ilike
>>> df = daft.from_pydict({"x": ["daft", "query", "engine"]})
>>> df = df.select(ilike(df["x"], "%ft%"))
>>> df.show()
╭───────╮
│ x     │
│ ---   │
│ Bool  │
╞═══════╡
│ true  │
├╌╌╌╌╌╌╌┤
│ false │
├╌╌╌╌╌╌╌┤
│ false │
╰───────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/str.py
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
def ilike(expr: Expression, pattern: str | Expression) -> Expression:
    """Checks whether each string matches the given SQL ILIKE pattern, case insensitive.

    Returns:
        Expression: a Boolean expression indicating whether each value matches the provided pattern

    Note:
        Use % as a multiple-character wildcard or _ as a single-character wildcard.

    Examples:
        >>> import daft
        >>> from daft.functions import ilike
        >>> df = daft.from_pydict({"x": ["daft", "query", "engine"]})
        >>> df = df.select(ilike(df["x"], "%ft%"))
        >>> df.show()
        ╭───────╮
        │ x     │
        │ ---   │
        │ Bool  │
        ╞═══════╡
        │ true  │
        ├╌╌╌╌╌╌╌┤
        │ false │
        ├╌╌╌╌╌╌╌┤
        │ false │
        ╰───────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    """
    return Expression._call_builtin_scalar_fn("ilike", expr, pattern)