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
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
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)