Skip to content

Conversation

@karuppuchamysuresh
Copy link
Contributor

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_numberInt64
    • rankInt64
    • dense_rankInt64
  2. Test window functions with generic return types:

    • lagNull (type depends on input)
    • leadNull (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:

Verification:

I've manually verified the current behavior:

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.

…schema

This test verifies that information_schema.routines correctly reports
return types for window functions (UDWFs). Before PR apache#20079, window
functions would show NULL for data_type. This test ensures the fix
works correctly and prevents regression.

Tests cover common window functions:
- row_number, rank, dense_rank (return Int64)
- lag, lead (return type depends on input, shown as Null)

The tests validate that:
1. Window functions now have proper data_type values (not NULL)
2. function_type correctly identifies them as 'WINDOW'
3. Return types match the actual behavior of each function

Closes apache#20090
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sqllogictest coverage for UDWF return types in information_schema

1 participant