@@ -5646,12 +5646,44 @@ fn skip_sql_whitespace(bytes: &[u8], mut i: usize) -> usize {
56465646 i
56475647}
56485648
5649+ fn skip_warning_identifier_comment ( bytes : & [ u8 ] , i : usize ) -> Option < usize > {
5650+ if i + 1 >= bytes. len ( ) {
5651+ return None ;
5652+ }
5653+
5654+ if bytes[ i] == b'-' && bytes[ i + 1 ] == b'-' {
5655+ let mut next = i + 2 ;
5656+ while next < bytes. len ( ) && bytes[ next] != b'\n' && bytes[ next] != b'\r' {
5657+ next += 1 ;
5658+ }
5659+ return Some ( next) ;
5660+ }
5661+
5662+ if bytes[ i] == b'/' && bytes[ i + 1 ] == b'*' {
5663+ let mut next = i + 2 ;
5664+ while next + 1 < bytes. len ( ) {
5665+ if bytes[ next] == b'*' && bytes[ next + 1 ] == b'/' {
5666+ return Some ( next + 2 ) ;
5667+ }
5668+ next += 1 ;
5669+ }
5670+ return Some ( bytes. len ( ) ) ;
5671+ }
5672+
5673+ None
5674+ }
5675+
56495676fn extract_where_filter_identifiers ( where_clause : & str ) -> Vec < String > {
56505677 let mut identifiers = Vec :: new ( ) ;
56515678 let bytes = where_clause. as_bytes ( ) ;
56525679 let mut i = 0 ;
56535680
56545681 while i < bytes. len ( ) {
5682+ if let Some ( next) = skip_warning_identifier_comment ( bytes, i) {
5683+ i = next;
5684+ continue ;
5685+ }
5686+
56555687 match bytes[ i] {
56565688 b'\'' => {
56575689 i = skip_quoted_sql ( bytes, i, b'\'' ) ;
@@ -7131,6 +7163,42 @@ FROM orders"#;
71317163 assert ! ( warning. contains( "year" ) ) ;
71327164 }
71337165
7166+ #[ test]
7167+ fn test_at_all_ignores_where_filter_line_comment_identifiers ( ) {
7168+ let source_dims = HashSet :: from ( [
7169+ normalize_identifier_name ( "year" ) ,
7170+ normalize_identifier_name ( "region" ) ,
7171+ ] ) ;
7172+ let warning = warning_for_at_all_ungrouped_where (
7173+ "revenue" ,
7174+ & [ ContextModifier :: All ( "region" . to_string ( ) ) ] ,
7175+ Some ( "TRUE -- year" ) ,
7176+ & [ "region" . to_string ( ) ] ,
7177+ & source_dims,
7178+ ) ;
7179+ assert ! ( warning. is_none( ) ) ;
7180+ }
7181+
7182+ #[ test]
7183+ fn test_at_all_ignores_at_where_block_comment_identifiers ( ) {
7184+ let source_dims = HashSet :: from ( [
7185+ normalize_identifier_name ( "year" ) ,
7186+ normalize_identifier_name ( "region" ) ,
7187+ ] ) ;
7188+ let warning = warning_for_at_all_ungrouped_where (
7189+ "revenue" ,
7190+ & [
7191+ ContextModifier :: All ( "region" . to_string ( ) ) ,
7192+ ContextModifier :: Where ( "1 = 1 /* year */" . to_string ( ) ) ,
7193+ ] ,
7194+ Some ( "year = 2024" ) ,
7195+ & [ "region" . to_string ( ) ] ,
7196+ & source_dims,
7197+ )
7198+ . unwrap ( ) ;
7199+ assert ! ( warning. contains( "year" ) ) ;
7200+ }
7201+
71347202 #[ test]
71357203 fn test_at_all_does_not_warn_when_at_where_encodes_filter_dimension ( ) {
71367204 let source_dims = HashSet :: from ( [
0 commit comments