apache / apache/datafusion

Normalize output column names for Window Functions to improve consistency

Open
#17,790 1 comment 0 reactions 1 assignee Claimed by @devampatel03 View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

Yes. While working on PR #17690 to fix alias naming issue (#17469), I noticed that the default output column name for `window functions` is inconsistent and overly verbose.

Currently, when a window function is used, the output column name includes the entire `OVER` clause (e.g., `PARTITION BY`, `ORDER BY`, etc.). This is undesirable because:
1. It creates extremely long and hard to read column headers.
2. It's inconsistent with other scalar and aggregate functions, which do not include these clauses in their column name.

### Describe the solution you'd like

I propose that we normalize the default output column naming for the `window functions`. The output column name should only include the function's name and its immediate arguments, not the details of the `OVER` clause.

* **Current Behavior:**
The output column name is `odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`.

* **Desired Behavior:**
The column name should simply be `odd_counter(t.val)`.

This would make the behavior of `window functions` consistent with other functions and significantly improve the readability of query results.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.