@@ -10,7 +10,6 @@ use url::Url;
1010
1111use crate :: Benchmark ;
1212use crate :: BenchmarkDataset ;
13- use crate :: Engine ;
1413use crate :: IdempotentPath ;
1514use crate :: TableSpec ;
1615use crate :: clickbench:: * ;
@@ -20,8 +19,6 @@ pub struct ClickBenchBenchmark {
2019 pub flavor : Flavor ,
2120 pub queries_file : Option < String > ,
2221 pub data_url : Url ,
23- /// Override the engine to select engine-specific query files.
24- pub engine : Option < Engine > ,
2522}
2623
2724impl ClickBenchBenchmark {
@@ -35,16 +32,9 @@ impl ClickBenchBenchmark {
3532 flavor,
3633 queries_file,
3734 data_url : url,
38- engine : None ,
3935 } )
4036 }
4137
42- /// Set the engine to select engine-specific query files.
43- pub fn with_engine ( mut self , engine : Engine ) -> Self {
44- self . engine = Some ( engine) ;
45- self
46- }
47-
4838 /// Returns the path to the queries file.
4939 fn queries_file_path ( & self ) -> PathBuf {
5040 if let Some ( file) = & self . queries_file {
@@ -54,21 +44,6 @@ impl ClickBenchBenchmark {
5444 manifest_dir. join ( "clickbench_queries.sql" )
5545 }
5646
57- /// Returns true if the engine requires unquoted column names.
58- fn uses_unquoted_identifiers ( & self ) -> bool {
59- matches ! ( self . engine, Some ( Engine :: ClickHouse ) )
60- }
61-
62- /// Strips double quotes only from simple SQL identifiers for engines like
63- /// ClickHouse that don't require quoted column names.
64- fn normalize_query ( & self , query : & str ) -> String {
65- if !self . uses_unquoted_identifiers ( ) {
66- return query. to_string ( ) ;
67- }
68-
69- strip_simple_identifier_quotes ( query)
70- }
71-
7247 fn create_data_url ( remote_data_dir : & Option < String > , flavor : Flavor ) -> Result < Url > {
7348 match remote_data_dir {
7449 None => {
@@ -96,64 +71,6 @@ impl ClickBenchBenchmark {
9671 }
9772}
9873
99- fn strip_simple_identifier_quotes ( query : & str ) -> String {
100- let bytes = query. as_bytes ( ) ;
101- let mut out = String :: with_capacity ( query. len ( ) ) ;
102- let mut i = 0 ;
103-
104- while i < query. len ( ) {
105- let rel = match query[ i..] . find ( '"' ) {
106- Some ( pos) => pos,
107- None => {
108- out. push_str ( & query[ i..] ) ;
109- break ;
110- }
111- } ;
112-
113- let start = i + rel;
114- out. push_str ( & query[ i..start] ) ;
115-
116- let mut end = start + 1 ;
117- while end < bytes. len ( ) {
118- if bytes[ end] == b'"' {
119- if end + 1 < bytes. len ( ) && bytes[ end + 1 ] == b'"' {
120- end += 2 ;
121- } else {
122- break ;
123- }
124- } else {
125- end += 1 ;
126- }
127- }
128-
129- if end >= bytes. len ( ) {
130- out. push_str ( & query[ start..] ) ;
131- break ;
132- }
133-
134- let inner = & query[ start + 1 ..end] ;
135- if is_simple_identifier ( inner) {
136- out. push_str ( inner) ;
137- } else {
138- out. push_str ( & query[ start..=end] ) ;
139- }
140-
141- i = end + 1 ;
142- }
143-
144- out
145- }
146-
147- fn is_simple_identifier ( s : & str ) -> bool {
148- let mut chars = s. chars ( ) ;
149- let Some ( first) = chars. next ( ) else {
150- return false ;
151- } ;
152-
153- ( first. is_ascii_alphabetic ( ) || first == '_' )
154- && chars. all ( |c| c. is_ascii_alphanumeric ( ) || c == '_' )
155- }
156-
15774#[ async_trait:: async_trait]
15875impl Benchmark for ClickBenchBenchmark {
15976 fn queries ( & self ) -> Result < Vec < ( usize , String ) > > {
@@ -163,7 +80,7 @@ impl Benchmark for ClickBenchBenchmark {
16380 . split ( ';' )
16481 . map ( |s| s. trim ( ) )
16582 . filter ( |s| !s. is_empty ( ) )
166- . map ( |s| self . normalize_query ( s ) )
83+ . map ( |s| s . to_string ( ) )
16784 . enumerate ( )
16885 . collect ( ) )
16986 }
0 commit comments