alamb commented on code in PR #11311:
URL: https://github.com/apache/datafusion/pull/11311#discussion_r1667754415


##########
datafusion/substrait/src/logical_plan/consumer.rs:
##########
@@ -1297,6 +1297,32 @@ pub async fn from_substrait_rex(
                         outer_ref_columns,
                     })))
                 }
+                SubqueryType::SetPredicate(predicate) => {
+                    match predicate.predicate_op {

Review Comment:
   It looks like we could use 
https://docs.rs/substrait/0.35.0/substrait/proto/expression/subquery/struct.SetPredicate.html#method.predicate_op
 to match on `PredicateOp` rather than a constant
   
   So lke
   
   ```rust
   match predicate.predicate_op() { 
     PredicateOp::Exists => ...
     other_type => ...
   }
   ```



##########
datafusion/substrait/tests/cases/consumer_integration.rs:
##########
@@ -180,4 +214,56 @@ mod tests {
         \n                  TableScan: FILENAME_PLACEHOLDER_1 
projection=[o_orderkey, o_custkey, o_orderstatus, o_totalprice, o_orderdate, 
o_orderpriority, o_clerk, o_shippriority, o_comment]\n                
TableScan: FILENAME_PLACEHOLDER_2 projection=[l_orderkey, l_partkey, l_suppkey, 
l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, 
l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, 
l_shipmode, l_comment]");
         Ok(())
     }
+
+    #[tokio::test]
+    async fn tpch_test_4() -> Result<()> {
+        let ctx = create_context_tpch4().await?;
+        let path = "tests/testdata/tpch_substrait_plans/query_4.json";
+        let proto = serde_json::from_reader::<_, Plan>(BufReader::new(
+            File::open(path).expect("file not found"),
+        ))
+        .expect("failed to parse json");
+        let plan = from_substrait_plan(&ctx, &proto).await?;
+        let plan_str = format!("{:?}", plan);
+        assert_eq!(plan_str, "Projection: 
FILENAME_PLACEHOLDER_0.o_orderpriority AS O_ORDERPRIORITY, count(Int64(1)) AS 
ORDER_COUNT\
+        \n  Sort: FILENAME_PLACEHOLDER_0.o_orderpriority ASC NULLS LAST\
+        \n    Aggregate: groupBy=[[FILENAME_PLACEHOLDER_0.o_orderpriority]], 
aggr=[[count(Int64(1))]]\
+        \n      Projection: FILENAME_PLACEHOLDER_0.o_orderpriority\
+        \n        Filter: FILENAME_PLACEHOLDER_0.o_orderdate >= 
CAST(Utf8(\"1993-07-01\") AS Date32) AND FILENAME_PLACEHOLDER_0.o_orderdate < 
CAST(Utf8(\"1993-10-01\") AS Date32) AND EXISTS (<subquery>)\

Review Comment:
   👍 



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to