This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new f5fa3a99630 [fix](doc) dev: fix array_count nested higher-order 
example (EN) (#3866)
f5fa3a99630 is described below

commit f5fa3a99630df7b5baa680020cb7a90009b200c3
Author: boluor <[email protected]>
AuthorDate: Tue Jun 2 00:00:07 2026 -0700

    [fix](doc) dev: fix array_count nested higher-order example (EN) (#3866)
    
    ## What
    
    The **dev EN** `array-count` page presented this nested higher-order
    example as if it works, claiming a result of `2`:
    
    ```sql
    SELECT array_count(x -> array_exists(y -> y > 5, x), 
[[1,2,3],[4,5,6],[7,8,9]]);
    ```
    
    But `array_exists` returns an **ARRAY** (one boolean per inner element),
    and `array_count` expects the lambda body to return a scalar it can cast
    to BOOLEAN. On a live cluster this errors:
    
    ```
    ERROR 1105 (HY000): errCode = 2, detailMessage =
      Can not find the compatibility function signature: 
array_count(ARRAY<ARRAY<BOOLEAN>>)
    ```
    
    ## Fix
    
    This is intended behavior, not a signature gap — the **dev ZH**, **v4.x
    ZH** and **v4.x EN** pages already document this exact error as the
    "lambda returns an array" failure case. This PR brings dev EN in line
    with the v4.x EN treatment: show the signature error, then give a
    working alternative whose lambda returns a scalar BOOLEAN:
    
    ```sql
    SELECT array_count(x -> size(array_filter(y -> y > 5, x)) > 0, 
[[1,2,3],[4,5,6],[7,8,9]]);
    -- 2
    ```
    
    ## Verified live
    
    Both statements run on a master daily build (`doris-0.0.0-2e72603618c`):
    the first reproduces the signature error verbatim, the second returns
    `2`.
    
    ## Scope
    
    **EN-only.** dev ZH, v4.x EN and v4.x ZH already document the error
    correctly, so no backport is needed.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
---
 .../scalar-functions/array-functions/array-count.md  | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md 
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md
index 803142af5c4..a65101d6715 100644
--- 
a/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/array-functions/array-count.md
@@ -165,14 +165,22 @@ SELECT array_count(x -> array_size(x) > 2, 
[[1,2],[1,2,3],[4,5,6,7]]);
 +----------------------------------------------------------------+
 ```
 
-Nested higher-order function example - count arrays that contain elements 
greater than 5:
+Nested higher-order functions — `array_count` expects the lambda body to 
return a scalar that can be cast to BOOLEAN. When the inner `array_exists` 
returns an ARRAY of booleans (one per inner element), `array_count` can not 
consume it and reports a signature error:
+
 ```sql
 SELECT array_count(x -> array_exists(y -> y > 5, x), 
[[1,2,3],[4,5,6],[7,8,9]]);
-+--------------------------------------------------+
-| array_count(x -> array_exists(y -> y > 5, x), [[1,2,3],[4,5,6],[7,8,9]]) |
-+--------------------------------------------------+
-|                                              2   |
-+--------------------------------------------------+
+ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the 
compatibility function signature: array_count(ARRAY<ARRAY<BOOLEAN>>)
+```
+
+To count outer arrays that contain *any* element greater than 5, wrap the 
inner check so the lambda returns a scalar BOOLEAN — e.g. `size(array_filter(y 
-> y > 5, x)) > 0`:
+
+```sql
+SELECT array_count(x -> size(array_filter(y -> y > 5, x)) > 0, 
[[1,2,3],[4,5,6],[7,8,9]]);
++----------------------------------------------------------------------------------+
+| array_count(x -> size(array_filter(y -> y > 5, x)) > 0, 
[[1,2,3],[4,5,6],[7,8,9]]) |
++----------------------------------------------------------------------------------+
+|                                                                              
  2 |
++----------------------------------------------------------------------------------+
 ```
 
 Literal array example:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to