From 0aa58311dbc9b8631397abecb4dc8d28f5940ceb Mon Sep 17 00:00:00 2001 From: Rakhi Prathap Date: Wed, 26 Mar 2025 10:32:33 +0530 Subject: [PATCH 1/4] add a note about removing null values --- .../pages/n1ql-language-reference/arrayfun.adoc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc index ea211d7ed..3def913fb 100644 --- a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc +++ b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc @@ -1157,11 +1157,23 @@ val1, val2, …:: [At least 1 is required] The input value or multiple values to Output Values:: A new array with all occurrences of the specified [.var]`val` or multiple [.var]`val` fields removed from the array [.var]`expr`. - ++ If any of the arguments are `MISSING`, then it returns `MISSING`. - ++ If the first argument is not an array, then it returns `NULL`. +[NOTE] +==== +This function cannot be used to remove NULL values from an array. +To remove NULL values, use the xref:n1ql-language-reference/collectionops.adoc#array[Array Collection Operator] instead. +For example: + +[source,sqlpp] +---- +SELECT ARRAY a FOR a IN [1, NULL, 2] WHEN a IS NOT NULL END AS filtered_array; +---- +==== + === Example ==== include::ROOT:partial$query-context.adoc[tag=example] From ad680fdcf3bf0e3d5ada6a7581b916c7204cde22 Mon Sep 17 00:00:00 2001 From: Rakhi Prathap Date: Wed, 26 Mar 2025 10:52:55 +0530 Subject: [PATCH 2/4] update example --- modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc index 3def913fb..d97098b56 100644 --- a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc +++ b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc @@ -1170,7 +1170,9 @@ For example: [source,sqlpp] ---- -SELECT ARRAY a FOR a IN [1, NULL, 2] WHEN a IS NOT NULL END AS filtered_array; +SELECT ARRAY name FOR name IN ["Ryan", NULL, "Corrine"] +WHEN name IS NOT NULL +END AS filtered_names; ---- ==== From 75d9011b854750287a478fdda829cbcbd3b813f9 Mon Sep 17 00:00:00 2001 From: Rakhi Prathap Date: Wed, 23 Apr 2025 10:40:20 +0530 Subject: [PATCH 3/4] edits based on engg feedback --- modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc index d97098b56..156728965 100644 --- a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc +++ b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc @@ -1164,7 +1164,9 @@ If the first argument is not an array, then it returns `NULL`. [NOTE] ==== -This function cannot be used to remove NULL values from an array. +This function cannot be used to remove NULL values from an array as it uses an equality predicate when evaluating the array elements to remove. +Since NULL does not equal NULL, such values are not matched and remain in the array. + To remove NULL values, use the xref:n1ql-language-reference/collectionops.adoc#array[Array Collection Operator] instead. For example: From 6a753afcca36d6e9652c3a6b0b3eccda51ad576e Mon Sep 17 00:00:00 2001 From: Rakhi Prathap Date: Wed, 23 Apr 2025 18:59:49 +0530 Subject: [PATCH 4/4] fix indentation --- modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc index 156728965..775589b7a 100644 --- a/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc +++ b/modules/n1ql/pages/n1ql-language-reference/arrayfun.adoc @@ -1161,7 +1161,7 @@ A new array with all occurrences of the specified [.var]`val` or multiple [.var] If any of the arguments are `MISSING`, then it returns `MISSING`. + If the first argument is not an array, then it returns `NULL`. - ++ [NOTE] ==== This function cannot be used to remove NULL values from an array as it uses an equality predicate when evaluating the array elements to remove.