@@ -182,104 +182,83 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
182182 }
183183 true
184184 } ;
185- match ( op, is_all) {
186- ( SetOperator :: Union , true ) => {
187- let left_schema = left_plan. output_schema ( ) ;
188- let right_schema = right_plan. output_schema ( ) ;
189-
190- if !fn_eq ( left_schema, right_schema) {
191- return Err ( DatabaseError :: MisMatch (
192- "the output types on the left" ,
193- "the output types on the right" ,
194- ) ) ;
195- }
196- Ok ( UnionOperator :: build (
197- left_schema. clone ( ) ,
198- right_schema. clone ( ) ,
199- left_plan,
200- right_plan,
201- ) )
202- }
203- ( SetOperator :: Union , false ) => {
204- let left_schema = left_plan. output_schema ( ) ;
205- let right_schema = right_plan. output_schema ( ) ;
206-
207- if !fn_eq ( left_schema, right_schema) {
208- return Err ( DatabaseError :: MisMatch (
209- "the output types on the left" ,
210- "the output types on the right" ,
211- ) ) ;
212- }
213- let union_op = Operator :: Union ( UnionOperator {
214- left_schema_ref : left_schema. clone ( ) ,
215- _right_schema_ref : right_schema. clone ( ) ,
216- } ) ;
217- let distinct_exprs = left_schema
218- . iter ( )
219- . cloned ( )
220- . map ( ScalarExpression :: ColumnRef )
221- . collect_vec ( ) ;
222-
223- Ok ( self . bind_distinct (
224- LogicalPlan :: new (
225- union_op,
226- Childrens :: Twins {
227- left : left_plan,
228- right : right_plan,
229- } ,
230- ) ,
231- distinct_exprs,
232- ) )
233- }
234- ( SetOperator :: Except , true ) => {
235- let left_schema = left_plan. output_schema ( ) ;
236- let right_schema = right_plan. output_schema ( ) ;
237-
238- if !fn_eq ( left_schema, right_schema) {
239- return Err ( DatabaseError :: MisMatch (
240- "the output types on the left" ,
241- "the output types on the right" ,
242- ) ) ;
185+
186+ let left_schema = left_plan. output_schema ( ) ;
187+ let right_schema = right_plan. output_schema ( ) ;
188+
189+ if !fn_eq ( left_schema, right_schema) {
190+ return Err ( DatabaseError :: MisMatch (
191+ "the output types on the left" ,
192+ "the output types on the right" ,
193+ ) ) ;
194+ }
195+
196+ match op {
197+ SetOperator :: Union => {
198+ if is_all {
199+ Ok ( UnionOperator :: build (
200+ left_schema. clone ( ) ,
201+ right_schema. clone ( ) ,
202+ left_plan,
203+ right_plan,
204+ ) )
205+ } else {
206+ let distinct_exprs = left_schema
207+ . iter ( )
208+ . cloned ( )
209+ . map ( ScalarExpression :: ColumnRef )
210+ . collect_vec ( ) ;
211+
212+ let union_op = Operator :: Union ( UnionOperator {
213+ left_schema_ref : left_schema. clone ( ) ,
214+ _right_schema_ref : right_schema. clone ( ) ,
215+ } ) ;
216+
217+ Ok ( self . bind_distinct (
218+ LogicalPlan :: new (
219+ union_op,
220+ Childrens :: Twins {
221+ left : left_plan,
222+ right : right_plan,
223+ } ,
224+ ) ,
225+ distinct_exprs,
226+ ) )
243227 }
244- Ok ( ExceptOperator :: build (
245- left_schema. clone ( ) ,
246- right_schema. clone ( ) ,
247- left_plan,
248- right_plan,
249- ) )
250228 }
251- ( SetOperator :: Except , false ) => {
252- let left_schema = left_plan. output_schema ( ) ;
253- let right_schema = right_plan. output_schema ( ) ;
254-
255- if !fn_eq ( left_schema, right_schema) {
256- return Err ( DatabaseError :: MisMatch (
257- "the output types on the left" ,
258- "the output types on the right" ,
259- ) ) ;
229+ SetOperator :: Except => {
230+ if is_all {
231+ Ok ( ExceptOperator :: build (
232+ left_schema. clone ( ) ,
233+ right_schema. clone ( ) ,
234+ left_plan,
235+ right_plan,
236+ ) )
237+ } else {
238+ let distinct_exprs = left_schema
239+ . iter ( )
240+ . cloned ( )
241+ . map ( ScalarExpression :: ColumnRef )
242+ . collect_vec ( ) ;
243+
244+ let except_op = Operator :: Except ( ExceptOperator {
245+ left_schema_ref : left_schema. clone ( ) ,
246+ _right_schema_ref : right_schema. clone ( ) ,
247+ } ) ;
248+
249+ Ok ( self . bind_distinct (
250+ LogicalPlan :: new (
251+ except_op,
252+ Childrens :: Twins {
253+ left : left_plan,
254+ right : right_plan,
255+ } ,
256+ ) ,
257+ distinct_exprs,
258+ ) )
260259 }
261- let except_op = Operator :: Except ( ExceptOperator {
262- left_schema_ref : left_schema. clone ( ) ,
263- _right_schema_ref : right_schema. clone ( ) ,
264- } ) ;
265- let distinct_exprs = left_schema
266- . iter ( )
267- . cloned ( )
268- . map ( ScalarExpression :: ColumnRef )
269- . collect_vec ( ) ;
270-
271- Ok ( self . bind_distinct (
272- LogicalPlan :: new (
273- except_op,
274- Childrens :: Twins {
275- left : left_plan,
276- right : right_plan,
277- } ,
278- ) ,
279- distinct_exprs,
280- ) )
281260 }
282- ( set_operator, _ ) => Err ( DatabaseError :: UnsupportedStmt ( format ! (
261+ set_operator => Err ( DatabaseError :: UnsupportedStmt ( format ! (
283262 "set operator: {:?}" ,
284263 set_operator
285264 ) ) ) ,
0 commit comments