Skip to content

Commit ef2686e

Browse files
committed
Skip comments when splitting SELECT items in alias extraction
extract_subquery_aliases_from_select now skips -- line comments and /* block comments */ so commas inside comments are not treated as SELECT item separators.
1 parent afd6e29 commit ef2686e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

yardstick-rs/src/sql/measures.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5504,6 +5504,23 @@ fn extract_subquery_aliases_from_select(sql: &str) -> Vec<String> {
55045504
}
55055505
}
55065506
}
5507+
b'-' if i + 1 < select_text.len() && bytes[i + 1] == b'-' => {
5508+
while i < select_text.len() && bytes[i] != b'\n' {
5509+
i += 1;
5510+
}
5511+
continue;
5512+
}
5513+
b'/' if i + 1 < select_text.len() && bytes[i + 1] == b'*' => {
5514+
i += 2;
5515+
while i + 1 < select_text.len() {
5516+
if bytes[i] == b'*' && bytes[i + 1] == b'/' {
5517+
i += 2;
5518+
break;
5519+
}
5520+
i += 1;
5521+
}
5522+
continue;
5523+
}
55075524
b',' if depth == 0 => {
55085525
if let Some(alias) = subquery_alias_from_item(&select_text[item_start..i]) {
55095526
aliases.push(alias);

0 commit comments

Comments
 (0)