jkosh44 commented on PR #14289:
URL: https://github.com/apache/datafusion/pull/14289#issuecomment-2628991328

   > If someone forgets to handle nulls in invoke, then don't we run the risk 
of accidentally returning different results depending on if the function was 
called with scalar arguments or with a batch of arguments?
   
   Though I'm still slightly concerned about this. For example if we run 
`array_slice` on a batch we get the following:
   
   ```
   > CREATE TABLE t (a int[], b int, c int);
   0 row(s) fetched. 
   Elapsed 0.004 seconds.
   
   > INSERT INTO t VALUES ([1,2,3], 1, 2), ([1,2,3], 1, 2), ([1,2,3], 1, 2), 
([1,2,3], 1, 2), ([1,2,3], 1, 2), ([1,2,3], 1, 2), ([1,2,3], 1, NULL), 
([1,2,3], NULL, 2), (NULL, 1, 2);
   +-------+
   | count |
   +-------+
   | 9     |
   +-------+
   1 row(s) fetched. 
   Elapsed 0.009 seconds.
   
   > SELECT array_slice(a, b, c) FROM t;
   +--------------+
   | t.a[t.b:t.c] |
   +--------------+
   | [1, 2]       |
   | [1, 2]       |
   | [1, 2]       |
   | [1, 2]       |
   | [1, 2]       |
   | [1, 2]       |
   | [1, 2, 3]    |
   | [1, 2]       |
   | []           |
   +--------------+
   9 row(s) fetched. 
   Elapsed 0.004 seconds.
   
   ```
   
   but if we just run in on scalars then we get the following:
   
   ```
   > SELECT array_slice([1,2,3], 1, NULL);
   +-------------------------------------------------------+
   | make_array(Int64(1),Int64(2),Int64(3))[Int64(1):NULL] |
   +-------------------------------------------------------+
   | NULL                                                  |
   +-------------------------------------------------------+
   1 row(s) fetched. 
   Elapsed 0.003 seconds.
   
   > SELECT array_slice([1,2,3], NULL, 2);
   +-------------------------------------------------------+
   | make_array(Int64(1),Int64(2),Int64(3))[NULL:Int64(2)] |
   +-------------------------------------------------------+
   | NULL                                                  |
   +-------------------------------------------------------+
   1 row(s) fetched. 
   Elapsed 0.004 seconds.
   
   > SELECT array_slice(arrow_cast(NULL, 'LargeList(Int64)'), 1, 2);
   +--------------------------------------------------------------+
   | arrow_cast(NULL,Utf8("LargeList(Int64)"))[Int64(1):Int64(2)] |
   +--------------------------------------------------------------+
   | NULL                                                         |
   +--------------------------------------------------------------+
   1 row(s) fetched. 
   Elapsed 0.005 seconds.
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to