LiaCastaneda commented on code in PR #27099:
URL: https://github.com/apache/datafusion/pull/27099#discussion_r4524109336


##########
datafusion/substrait/src/logical_plan/consumer/rel/set_rel.rs:
##########
@@ -3,74 +3,138 @@
 // SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) 
under one or more contributor license agreements
 
 use crate::logical_plan::consumer::SubstraitConsumer;
+use crate::logical_plan::consumer::expr::{
+    contains_struct, is_literal, name_struct_literal_like,
+};
 use datafusion::arrow::datatypes::Field;
 use datafusion::common::{JoinType, NullEquality, not_impl_err, substrait_err};
 use datafusion::logical_expr::{
-    Cast, Expr, LogicalPlan, LogicalPlanBuilder, requalify_sides_if_needed,
+    Cast, Expr, LogicalPlan, LogicalPlanBuilder, Projection, 
requalify_sides_if_needed,
 };
 use std::sync::Arc;
+use substrait::proto::SetRel;
 use substrait::proto::set_rel::SetOp;
-use substrait::proto::{Rel, SetRel};
 
 pub async fn from_set_rel(
     consumer: &impl SubstraitConsumer,
     set: &SetRel,
 ) -> datafusion::common::Result<LogicalPlan> {
     if set.inputs.len() < 2 {
-        substrait_err!("Set operation requires at least two inputs")
-    } else {
-        match set.op() {
-            SetOp::UnionAll => union_rels(consumer, &set.inputs, true).await,
-            SetOp::UnionDistinct => union_rels(consumer, &set.inputs, 
false).await,
-            SetOp::IntersectionPrimary => intersect_rel(
-                consumer.consume_rel(&set.inputs[0]).await?,
-                union_rels(consumer, &set.inputs[1..], true).await?,
-                false,
-            ),
-            SetOp::IntersectionMultiset => {
-                intersect_rels(consumer, &set.inputs, false).await
-            }
-            SetOp::IntersectionMultisetAll => {
-                intersect_rels(consumer, &set.inputs, true).await
-            }
-            SetOp::MinusPrimary => except_rels(consumer, &set.inputs, 
false).await,
-            SetOp::MinusPrimaryAll => except_rels(consumer, &set.inputs, 
true).await,
-            set_op => not_impl_err!("Unsupported set operator: {set_op:?}"),
+        return substrait_err!("Set operation requires at least two inputs");
+    }
+    let mut inputs = Vec::with_capacity(set.inputs.len());
+    for input in &set.inputs {
+        inputs.push(consumer.consume_rel(input).await?);
+    }
+    let mut inputs = name_struct_literal_columns(inputs)?;

Review Comment:
   Added a regression test + the fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to