Skip to content

fix: normalize window ident #15639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2025
Merged

fix: normalize window ident #15639

merged 2 commits into from
Apr 12, 2025

Conversation

chenkovsky
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

ident normalizer is not called.

What changes are included in this PR?

normalize ident before comparing window name.

Are these changes tested?

UT

Are there any user-facing changes?

NO

@chenkovsky chenkovsky marked this pull request as ready for review April 8, 2025 14:57
@github-actions github-actions bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Apr 8, 2025

// If there are any multiple-defined windows, we raise an error.
fn check_conflicting_windows(window_defs: &[NamedWindowDefinition]) -> Result<()> {
for (i, window_def_i) in window_defs.iter().enumerate() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this method for identifying duplicate named windows? if so probably we can simplify this a little bit like

let mut seen = HashSet::new();
for (name, _) in window_defs {
    if !seen.insert(name) {
        return plan_err!("The window {} is defined multiple times!", name);
    }
}

Copy link
Contributor Author

@chenkovsky chenkovsky Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't modified this method, It was there before I changed this file. I think your suggestion make sense, but maybe we can change it in another PR.

return ControlFlow::Break(());
// All named windows must be defined with a WindowSpec.
if let Some(WindowType::NamedWindow(ident)) = &f.over {
err = Some(DataFusionError::Plan(format!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenkovsky can you make a favor and change this to plan_err!?

4 11
5 16

# window definitions with aliases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it the same test as above? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the difference is lower case & upper case.

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chenkovsky this lgtm

@alamb alamb merged commit 8b1c84d into apache:main Apr 12, 2025
27 checks passed
@alamb
Copy link
Contributor

alamb commented Apr 12, 2025

Thanks @chenkovsky and @comphead

nirnayroy pushed a commit to nirnayroy/datafusion that referenced this pull request May 2, 2025
* fix: normalize window name

* format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support window definitions with aliases
3 participants