ARRAY_REMOVE_FIRST
Removes the first occurrence of an element from an array.
Syntax
ARRAY_REMOVE_FIRST(array, element)
Parameters
Return Type
Array with the first occurrence of the specified element removed.
Notes
This function works with both standard array types and variant array types.
Examples
Example 1: Removing from a Standard Array
SELECT ARRAY_REMOVE_FIRST([1, 2, 2, 3], 2);
Result:
[1, 2, 3]
Example 2: Removing from a Variant Array
SELECT ARRAY_REMOVE_FIRST(PARSE_JSON('["apple", "banana", "apple", "orange"]'), 'apple');
Result:
["banana", "apple", "orange"]
Example 3: Element Not Found
SELECT ARRAY_REMOVE_FIRST([1, 2, 3], 4);
Result:
[1, 2, 3]