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

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


The following commit(s) were added to refs/heads/master by this push:
     new f47fef71c6d [Fix](func) fix element_at return err when short-circuit 
evaluation passes empty input (#60570)
f47fef71c6d is described below

commit f47fef71c6d7a773598a5b7ea27537966345e32d
Author: linrrarity <[email protected]>
AuthorDate: Mon Feb 9 10:16:31 2026 +0800

    [Fix](func) fix element_at return err when short-circuit evaluation passes 
empty input (#60570)
    
    The `element_at` branch is completely short-circuited, causing `rows ==
    0`. The original line of code throws an error when `rows <= 0`
---
 .../vec/functions/array/function_array_element.h   |  7 -------
 .../basic-elements/data-types/map-md.out           |  4 ++++
 .../basic-elements/data-types/map-md.groovy        | 24 +++++++++++++++++++++-
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/be/src/vec/functions/array/function_array_element.h 
b/be/src/vec/functions/array/function_array_element.h
index 7f6b9572f0a..cda324d9db2 100644
--- a/be/src/vec/functions/array/function_array_element.h
+++ b/be/src/vec/functions/array/function_array_element.h
@@ -278,13 +278,6 @@ private:
         auto val_arr =
                 ColumnArray::create(map_column.get_values_ptr(), 
map_column.get_offsets_ptr());
 
-        const auto& offsets = map_column.get_offsets();
-        const size_t rows = offsets.size();
-        if (rows <= 0) {
-            return nullptr;
-        }
-        if (key_arr->is_nullable()) {
-        }
         ColumnPtr matched_indices = _get_mapped_idx(*key_arr, arguments[1]);
         if (!matched_indices) {
             return nullptr;
diff --git 
a/regression-test/data/doc/sql-manual/basic-elements/data-types/map-md.out 
b/regression-test/data/doc/sql-manual/basic-elements/data-types/map-md.out
index b78d389f6a3..a9030f76745 100644
--- a/regression-test/data/doc/sql-manual/basic-elements/data-types/map-md.out
+++ b/regression-test/data/doc/sql-manual/basic-elements/data-types/map-md.out
@@ -102,6 +102,10 @@ value1
 -- !sql --
 20
 
+-- !element_at_short_circuit_evaluation_test --
+\N
+\N
+
 -- !sql --
 0
 
diff --git 
a/regression-test/suites/doc/sql-manual/basic-elements/data-types/map-md.groovy 
b/regression-test/suites/doc/sql-manual/basic-elements/data-types/map-md.groovy
index 63b8298ef9e..a48f63efa00 100644
--- 
a/regression-test/suites/doc/sql-manual/basic-elements/data-types/map-md.groovy
+++ 
b/regression-test/suites/doc/sql-manual/basic-elements/data-types/map-md.groovy
@@ -399,7 +399,29 @@ suite("map-md", "p0") {
     qt_sql """ SELECT {'Alice': 20}['Alice']; """
 
     qt_sql """ SELECT ELEMENT_AT({'Alice': 20}, 'Alice');"""
-    
+
+    // test whether ELEMENT_AT executes normally in short-circuit-evaluation
+    sql """ DROP TABLE IF EXISTS test_map_sc; """
+    sql """ CREATE TABLE test_map_sc (
+                id INT,
+                join_key DATE,
+                col_map MAP<DATEV2, DATEV2>
+            )PROPERTIES ("replication_num" = "1");
+    """
+    sql """INSERT INTO test_map_sc VALUES
+            (1, '2024-01-01', {'2024-01-01': '2024-01-02'}),
+            (2, '2024-01-02', {'2024-01-01': '2024-01-03'});
+    """
+    sql """ SET short_circuit_evaluation = true; """
+    qt_element_at_short_circuit_evaluation_test """ 
+        SELECT
+            CASE
+                WHEN id > 0 THEN 1
+                ELSE element_at(col_map, DATE '2024-01-01')
+            END
+        FROM test_map_sc;
+    """
+    sql """ SET short_circuit_evaluation = false; """
     
     qt_sql """ DROP TABLE IF EXISTS ${tableName}; """
     sql """


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

Reply via email to