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

    ## What changes were proposed in this pull request?                         
                                                                                
                                                                                
  
                                                                                
                                                                                
                                                                                
   
     Add sqllogictest coverage to verify that `information_schema.routines` 
correctly reports return types for window user-defined functions (UDWFs).       
                                                                                
       
                                                                                
                                                                                
                                                                                
   
     ## Why are the changes needed?                                             
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     PR #20079 updated the information schema to use newer APIs for reporting 
function return types. Previously, window functions always showed `NULL` for 
their return type in `information_schema.routines`. The implementation was 
fixed but    
     lacked test coverage to prevent regression.                                
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     This PR adds tests specifically for the `get_udwf_args_and_return_types` 
code path in `datafusion/catalog/src/information_schema.rs`.                    
                                                                                
     
                                                                                
                                                                                
                                                                                
   
     ## Which issue does this PR close?                                         
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     Closes #20090                                                              
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     ## What tests are included?                                                
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     This PR adds 6 test cases to 
`datafusion/sqllogictest/test_files/information_schema.slt`:                    
                                                                                
                                                 
                                                                                
                                                                                
                                                                                
   
     1. **Test window functions with concrete return types:**                   
                                                                                
                                                                                
   
        - `row_number` → `Int64`                                                
                                                                                
                                                                                
   
        - `rank` → `Int64`                                                      
                                                                                
                                                                                
   
        - `dense_rank` → `Int64`                                                
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     2. **Test window functions with generic return types:**                    
                                                                                
                                                                                
   
        - `lag` → `Null` (type depends on input)                                
                                                                                
                                                                                
   
        - `lead` → `Null` (type depends on input)                               
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     3. **Combined test:**                                                      
                                                                                
                                                                                
   
        - Verifies multiple window functions together                           
                                                                                
                                                                                
   
        - Checks `is_deterministic` flag                                        
                                                                                
                                                                                
   
        - Tests ordering of results                                             
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     ## Before this PR (current behavior):                                      
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     All window functions show `NULL` for `data_type`:                          
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     +--------------+-----------+---------------+                               
                                                                                
                                                                                
   
     | routine_name | data_type | function_type |                               
                                                                                
                                                                                
   
     +--------------+-----------+---------------+                               
                                                                                
                                                                                
   
     | row_number   | NULL      | WINDOW        |                               
                                                                                
                                                                                
   
     | rank         | NULL      | WINDOW        |                               
                                                                                
                                                                                
   
     | dense_rank   | NULL      | WINDOW        |                               
                                                                                
                                                                                
   
     +--------------+-----------+---------------+                               
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     ## After PR #20079 merges (expected behavior):                             
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     Window functions will show proper return types:                            
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     +--------------+-----------+---------------+                               
                                                                                
                                                                                
   
     | routine_name | data_type | function_type |                               
                                                                                
                                                                                
   
     +--------------+-----------+---------------+                               
                                                                                
                                                                                
   
     | row_number   | Int64     | WINDOW        |                               
                                                                                
                                                                                
   
     | rank         | Int64     | WINDOW        |                               
                                                                                
                                                                                
   
     | dense_rank   | Int64     | WINDOW        |                               
                                                                                
                                                                                
   
     +--------------+-----------+---------------+                               
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     ## Dependencies                                                            
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     ⚠️ **This PR depends on #20079**                                           
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     The tests in this PR will fail until #20079 is merged because the 
underlying implementation doesn't yet report window function return types 
correctly. Once #20079 merges, these tests will pass and ensure the fix works 
correctly.          
                                                                                
                                                                                
                                                                                
   
     ## Are there any user-facing changes?                                      
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     No, this only adds test coverage. The functionality change is in PR 
#20079.                                                                         
                                                                                
          
                                                                                
                                                                                
                                                                                
   
     ---                                                                        
                                                                                
                                                                                
   
     📝 Initial Comment (Add After Creating PR)                                  
                                                                                
                                                                                
  
                                                                                
                                                                                
                                                                                
   
     ### Status                                                                 
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     This PR is marked as **Draft** because it depends on #20079 being merged 
first.                                                                          
                                                                                
     
                                                                                
                                                                                
                                                                                
   
     **Current test status:**                                                   
                                                                                
                                                                                
   
     - ✅ All test syntax is correct                                             
                                                                                
                                                                                
  
     - ⚠️ Tests currently fail (expected - they detect the bug that #20079 
fixes)                                                                          
                                                                                
        
     - ✅ Tests will pass once #20079 merges                                     
                                                                                
                                                                                
  
                                                                                
                                                                                
                                                                                
   
     **Verification:**                                                          
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     I've manually verified the current behavior:                               
                                                                                
                                                                                
   
     ```sql                                                                     
                                                                                
                                                                                
   
     select routine_name, data_type, function_type                              
                                                                                
                                                                                
   
     from information_schema.routines                                           
                                                                                
                                                                                
   
     where routine_name = 'row_number';                                         
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     Current result: row_number | NULL | WINDOW                                 
                                                                                
                                                                                
   
     Expected after #20079: row_number | Int64 | WINDOW                         
                                                                                
                                                                                
   
                                                                                
                                                                                
                                                                                
   
     This PR will be ready for review as soon as #20079 is merged.


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