@@ -2,6 +2,7 @@ use std::collections::HashMap;
2
2
use std:: vec;
3
3
4
4
use gitql_ast:: statement:: DescribeStatement ;
5
+ use gitql_ast:: statement:: Distinct ;
5
6
use gitql_ast:: statement:: DoStatement ;
6
7
use gitql_ast:: statement:: GQLQuery ;
7
8
use gitql_ast:: statement:: GlobalVariableStatement ;
@@ -90,6 +91,7 @@ fn evaluate_select_query(
90
91
let mut statements_map = query. statements ;
91
92
let has_group_by_statement = statements_map. contains_key ( "group" ) ;
92
93
94
+ let mut distinct: Option < Distinct > = None ;
93
95
for logical_node_name in FIXED_LOGICAL_PLAN {
94
96
if let Some ( statement) = statements_map. get_mut ( logical_node_name) {
95
97
match logical_node_name {
@@ -115,12 +117,7 @@ fn evaluate_select_query(
115
117
return Ok ( EvaluationResult :: SelectedGroups ( gitql_object) ) ;
116
118
}
117
119
118
- // Apply the distinct operation object is not empty too.
119
- apply_distinct_operator (
120
- & select_statement. distinct ,
121
- & mut gitql_object,
122
- & hidden_selections,
123
- ) ;
120
+ distinct = Some ( select_statement. distinct . to_owned ( ) ) ;
124
121
}
125
122
_ => {
126
123
execute_statement (
@@ -137,6 +134,11 @@ fn evaluate_select_query(
137
134
}
138
135
}
139
136
137
+ // Apply the distinct operation after executing statements
138
+ if let Some ( distinct) = distinct {
139
+ apply_distinct_operator ( & distinct, & mut gitql_object, & hidden_selections) ;
140
+ }
141
+
140
142
// Remove Hidden Selection from the rows after executing the query plan
141
143
remove_hidden_selected_from_groups (
142
144
& mut gitql_object. titles ,
0 commit comments