File tree 4 files changed +42
-0
lines changed
4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -3239,6 +3239,9 @@ pub enum Statement {
3239
3239
///
3240
3240
/// [SQLite](https://sqlite.org/lang_explain.html)
3241
3241
query_plan : bool ,
3242
+ /// `EXPLAIN ESTIMATE`
3243
+ /// [Clickhouse](https://clickhouse.com/docs/en/sql-reference/statements/explain#explain-estimate)
3244
+ estimate : bool ,
3242
3245
/// A SQL query that specifies what to explain
3243
3246
statement : Box < Statement > ,
3244
3247
/// Optional output format of explain
@@ -3471,6 +3474,7 @@ impl fmt::Display for Statement {
3471
3474
verbose,
3472
3475
analyze,
3473
3476
query_plan,
3477
+ estimate,
3474
3478
statement,
3475
3479
format,
3476
3480
options,
@@ -3483,6 +3487,9 @@ impl fmt::Display for Statement {
3483
3487
if * analyze {
3484
3488
write ! ( f, "ANALYZE " ) ?;
3485
3489
}
3490
+ if * estimate {
3491
+ write ! ( f, "ESTIMATE " ) ?;
3492
+ }
3486
3493
3487
3494
if * verbose {
3488
3495
write ! ( f, "VERBOSE " ) ?;
Original file line number Diff line number Diff line change @@ -298,6 +298,7 @@ define_keywords!(
298
298
ERROR ,
299
299
ESCAPE ,
300
300
ESCAPED ,
301
+ ESTIMATE ,
301
302
EVENT ,
302
303
EVERY ,
303
304
EXCEPT ,
Original file line number Diff line number Diff line change @@ -9091,6 +9091,7 @@ impl<'a> Parser<'a> {
9091
9091
let mut analyze = false;
9092
9092
let mut verbose = false;
9093
9093
let mut query_plan = false;
9094
+ let mut estimate = false;
9094
9095
let mut format = None;
9095
9096
let mut options = None;
9096
9097
@@ -9103,6 +9104,8 @@ impl<'a> Parser<'a> {
9103
9104
options = Some(self.parse_utility_options()?)
9104
9105
} else if self.parse_keywords(&[Keyword::QUERY, Keyword::PLAN]) {
9105
9106
query_plan = true;
9107
+ } else if self.parse_keyword(Keyword::ESTIMATE) {
9108
+ estimate = true;
9106
9109
} else {
9107
9110
analyze = self.parse_keyword(Keyword::ANALYZE);
9108
9111
verbose = self.parse_keyword(Keyword::VERBOSE);
@@ -9120,6 +9123,7 @@ impl<'a> Parser<'a> {
9120
9123
analyze,
9121
9124
verbose,
9122
9125
query_plan,
9126
+ estimate,
9123
9127
statement: Box::new(statement),
9124
9128
format,
9125
9129
options,
Original file line number Diff line number Diff line change @@ -4375,6 +4375,7 @@ fn run_explain_analyze(
4375
4375
analyze,
4376
4376
verbose,
4377
4377
query_plan,
4378
+ estimate,
4378
4379
statement,
4379
4380
format,
4380
4381
options,
@@ -4384,6 +4385,7 @@ fn run_explain_analyze(
4384
4385
assert_eq ! ( format, expected_format) ;
4385
4386
assert_eq ! ( options, exepcted_options) ;
4386
4387
assert ! ( !query_plan) ;
4388
+ assert ! ( !estimate) ;
4387
4389
assert_eq ! ( "SELECT sqrt(id) FROM foo" , statement. to_string( ) ) ;
4388
4390
}
4389
4391
_ => panic ! ( "Unexpected Statement, must be Explain" ) ,
@@ -4528,6 +4530,34 @@ fn parse_explain_query_plan() {
4528
4530
) ;
4529
4531
}
4530
4532
4533
+ #[ test]
4534
+ fn parse_explain_estimate ( ) {
4535
+ let statement = all_dialects ( ) . verified_stmt ( "EXPLAIN ESTIMATE SELECT sqrt(id) FROM foo" ) ;
4536
+
4537
+ match & statement {
4538
+ Statement :: Explain {
4539
+ query_plan,
4540
+ estimate,
4541
+ analyze,
4542
+ verbose,
4543
+ statement,
4544
+ ..
4545
+ } => {
4546
+ assert ! ( estimate) ;
4547
+ assert ! ( !query_plan) ;
4548
+ assert ! ( !analyze) ;
4549
+ assert ! ( !verbose) ;
4550
+ assert_eq ! ( "SELECT sqrt(id) FROM foo" , statement. to_string( ) ) ;
4551
+ }
4552
+ _ => unreachable ! ( ) ,
4553
+ }
4554
+
4555
+ assert_eq ! (
4556
+ "EXPLAIN ESTIMATE SELECT sqrt(id) FROM foo" ,
4557
+ statement. to_string( )
4558
+ ) ;
4559
+ }
4560
+
4531
4561
#[ test]
4532
4562
fn parse_named_argument_function ( ) {
4533
4563
let dialects = all_dialects_where ( |d| {
You can’t perform that action at this time.
0 commit comments