|
14 | 14 |
|
15 | 15 | use std::collections::HashMap; |
16 | 16 | use std::collections::HashSet; |
| 17 | +use std::collections::hash_map::Entry; |
17 | 18 | use std::sync::Arc; |
18 | 19 |
|
19 | 20 | use databend_common_ast::Span; |
@@ -97,9 +98,25 @@ impl Binder { |
97 | 98 | let mut window_specs = HashMap::new(); |
98 | 99 | let mut resolved_window_specs = HashMap::new(); |
99 | 100 | for window in window_list { |
100 | | - window_specs.insert(window.name.name.clone(), window.spec.clone()); |
101 | | - if window.spec.existing_window_name.is_none() { |
102 | | - resolved_window_specs.insert(window.name.name.clone(), window.spec.clone()); |
| 101 | + let window_name = self.normalize_identifier(&window.name).name; |
| 102 | + let mut window_spec = window.spec.clone(); |
| 103 | + if let Some(existing_window_name) = &mut window_spec.existing_window_name { |
| 104 | + *existing_window_name = self.normalize_identifier(existing_window_name); |
| 105 | + } |
| 106 | + |
| 107 | + match window_specs.entry(window_name.clone()) { |
| 108 | + Entry::Vacant(entry) => { |
| 109 | + entry.insert(window_spec.clone()); |
| 110 | + } |
| 111 | + Entry::Occupied(_) => { |
| 112 | + return Err(ErrorCode::SemanticError(format!( |
| 113 | + "Duplicate window name: {window_name}" |
| 114 | + ))); |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + if window_spec.existing_window_name.is_none() { |
| 119 | + resolved_window_specs.insert(window_name, window_spec); |
103 | 120 | } |
104 | 121 | } |
105 | 122 | Ok((window_specs, resolved_window_specs)) |
|
0 commit comments