alan910127 opened a new pull request, #14468:
URL: https://github.com/apache/datafusion/pull/14468

   ## Which issue does this PR close?
   
   Closes #13819.  
   
   ## Rationale for this change  
   
   Currently, `FixedSizeList` values inside a `make_array` call are eagerly 
coerced into `List`, resulting in non-intuitive behavior.  
   
   To improve consistency, this PR aligns the behavior with DuckDB: coercion 
should only occur when the `FixedSizeList` is modified. This approach makes 
coercion more predictable and avoids unnecessary type transformations.  
   
   ## What changes are included in this PR?  
   
   This PR removes the coercion logic in `make_array` when the type union 
resolves to `FixedSizeList`, ensuring that `make_array` no longer performs 
eager coercion.  
   
   ### Creating `List(FixedSizeList)`  
   
   Previously, `make_array` would automatically coerce `FixedSizeList` into 
`List`, even when no operations were performed. With this fix, the expected 
behavior is preserved:  
   
   ```sql
   > SELECT arrow_typeof([arrow_cast([1, 2, 3], 'FixedSizeList(3, Int64)')]);
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | 
arrow_typeof(make_array(arrow_cast(make_array(Int64(1),Int64(2),Int64(3)),Utf8("FixedSizeList(3,
 Int64)"))))                                                                    
                                                        |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | List(Field { name: "item", data_type: FixedSizeList(Field { name: "item", 
data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: 
{} }, 3), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }) |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   1 row(s) fetched.
   Elapsed 0.002 seconds.
   ```  
   
   ### Appending After Casting to `FixedSizeList`  
   
   If an element is appended to a `FixedSizeList`, coercion to `List` will 
still occur, as expected:  
   
   ```sql
   > SELECT arrow_typeof([array_append(arrow_cast([1, 2, 3], 'FixedSizeList(3, 
Int64)'), 4)]);
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | 
arrow_typeof(make_array(array_append(arrow_cast(make_array(Int64(1),Int64(2),Int64(3)),Utf8("FixedSizeList(3,
 Int64)")),Int64(4))))                                                          
                               |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | List(Field { name: "item", data_type: List(Field { name: "item", 
data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: 
{} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }) |
   
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   1 row(s) fetched.
   Elapsed 0.002 seconds.
   ```  
   
   ## Are these changes tested?  
   
   One of the test cases in `sqllogictest` has been modified to reflect the 
updated behavior.  
   
   ## Are there any user-facing changes?  
   
   Yes, users who previously relied on `make_array` coercing `FixedSizeList` 
into `List` by default will see a change in behavior. Now, coercion only occurs 
when modifications (e.g., `array_append`) are applied.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to