jatin510 opened a new issue, #13872:
URL: https://github.com/apache/datafusion/issues/13872

   ### Describe the bug
   
   How `array_repeat` works currently for `null` as input in array or key:
   
   ```
   > SELECT array_repeat(null,0 ) AS repeated_array;
   +----------------+
   | repeated_array |
   +----------------+
   | []             |
   +----------------+
   1 row(s) fetched. 
   Elapsed 0.006 seconds.
   
   > SELECT array_repeat(null,1 ) AS repeated_array;
   +----------------+
   | repeated_array |
   +----------------+
   | []             |
   +----------------+
   1 row(s) fetched. 
   Elapsed 0.002 seconds.
   
   > SELECT array_repeat(null,2 ) AS repeated_array;
   +----------------+
   | repeated_array |
   +----------------+
   | [, ]           |
   +----------------+
   1 row(s) fetched. 
   Elapsed 0.004 seconds.
   
   > SELECT array_repeat(ARRAY[1, 2], null) AS repeated_array;
   Internal error: could not cast value to 
arrow_array::array::primitive_array::PrimitiveArray<arrow_array::types::Int64Type>.
   This was likely caused by a bug in DataFusion's code and we would welcome 
that you file an bug report in our issue tracker
   ```
   
   is this a desired behaviour ?
   
   - why : `SELECT array_repeat(null,0 ) AS repeated_array;` & `SELECT 
array_repeat(null,1) AS repeated_array;` are same ?
   
   - if we check this out, the length is also not same, 
   but above both look same ?
   ```
   > SELECT ARRAY_LENGTH(array_repeat(null, 1));
   
   +-------------------------------------------+
   | array_length(array_repeat(NULL,Int64(1))) |
   +-------------------------------------------+
   | 1                                         |
   +-------------------------------------------+
   1 row(s) fetched. 
   Elapsed 0.006 seconds.
   
   > SELECT ARRAY_LENGTH(array_repeat(null, 0));
   +-------------------------------------------+
   | array_length(array_repeat(NULL,Int64(0))) |
   +-------------------------------------------+
   | 0                                         |
   +-------------------------------------------+
   ```
   
   
   
   
   When I was trying to use them with `datafusion-comet`. I found out spark 
works differently with `NULL` as input 
   
   ```
   spark-sql (default)>  SELECT a, b, c, array_repeat(null , 0) AS 
array_after_removal from temp_table;
   4    NULL    22      []
   1    2       3       []
   Time taken: 0.138 seconds, Fetched 6 row(s)
   spark-sql (default)>  SELECT a, b, c, array_repeat(null , 1) AS 
array_after_removal from temp_table;
   NULL 2323    22      [null]
   4    NULL    22      [null]
   1    2       3       [null]
   Time taken: 0.107 seconds, Fetched 6 row(s)
   spark-sql (default)>  SELECT a, b, c, array_repeat(array(a, b, c), null) AS 
array_after_removal from temp_table;
   NULL 2323    22      NULL
   4    NULL    22      NULL
   ```
   
   
   ### To Reproduce
   
   _No response_
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   Is this the desired behaviour of `array_repeat` or we going to make some 
changes to the functionality, especially in case of 
   `array_repeat(null, 1)` and `array_repeat(null, 0)`


-- 
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.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