Skip to content

Commit 85997e1

Browse files
SNOW-2442548 Include VARIANT cast requirement for array_contains(...) (#3948)
1 parent db81491 commit 85997e1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/snowflake/snowpark/functions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7135,10 +7135,15 @@ def array_contains(
71357135
variant: Column containing the VARIANT to find.
71367136
array: Column containing the ARRAY to search.
71377137

7138+
If this is a semi-structured array, you're required to explicitly cast the following SQL types into a VARIANT:
7139+
7140+
- `String & Binary <https://docs.snowflake.com/en/sql-reference/data-types-text>`_
7141+
- `Date & Time <https://docs.snowflake.com/en/sql-reference/data-types-datetime>`_
7142+
71387143
Example::
71397144
>>> from snowflake.snowpark import Row
7140-
>>> df = session.create_dataframe([Row([1, 2]), Row([1, 3])], schema=["a"])
7141-
>>> df.select(array_contains(lit(2), "a").alias("result")).show()
7145+
>>> df = session.create_dataframe([Row(["apple", "banana"]), Row(["apple", "orange"])], schema=["a"])
7146+
>>> df.select(array_contains(lit("banana").cast("variant"), "a").alias("result")).show()
71427147
------------
71437148
|"RESULT" |
71447149
------------

0 commit comments

Comments
 (0)