mingmwang commented on PR #5264: URL: https://github.com/apache/arrow-datafusion/pull/5264#issuecomment-1437070399
One more thing, looks like the SubqueryAlias logic is not consistent between the two rules `DecorrelateWhereExists` and `DecorrelateWhereIn` https://github.com/apache/arrow-datafusion/pull/4767 I think you can make them consistent in the refactoring work. ```rust let sql = "SELECT t1_id, t1_name FROM t1 WHERE t1_id IN (SELECT t2_id FROM t2) ORDER BY t1_id"; let msg = format!("Creating logical plan for '{sql}'"); let dataframe = ctx.sql(&("explain ".to_owned() + sql)).await.expect(&msg); let plan = dataframe.into_optimized_plan()?; let expected = vec![ "Explain [plan_type:Utf8, plan:Utf8]", " Sort: t1.t1_id ASC NULLS LAST [t1_id:UInt32;N, t1_name:Utf8;N]", " Projection: t1.t1_id, t1.t1_name [t1_id:UInt32;N, t1_name:Utf8;N]", " LeftSemi Join: t1.t1_id = __correlated_sq_1.t2_id [t1_id:UInt32;N, t1_name:Utf8;N]", " TableScan: t1 projection=[t1_id, t1_name] [t1_id:UInt32;N, t1_name:Utf8;N]", " SubqueryAlias: __correlated_sq_1 [t2_id:UInt32;N]", " Projection: t2.t2_id AS t2_id [t2_id:UInt32;N]", " TableScan: t2 projection=[t2_id] [t2_id:UInt32;N]", ]; ``` ```rust let sql = "SELECT t1_id, t1_name FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE t1_id = t2_id and t1_id > 11) ORDER BY t1_id"; let msg = format!("Creating logical plan for '{sql}'"); let dataframe = ctx.sql(&("explain ".to_owned() + sql)).await.expect(&msg); let plan = dataframe.into_optimized_plan()?; let expected = vec![ "Explain [plan_type:Utf8, plan:Utf8]", " Sort: t1.t1_id ASC NULLS LAST [t1_id:UInt32;N, t1_name:Utf8;N]", " Projection: t1.t1_id, t1.t1_name [t1_id:UInt32;N, t1_name:Utf8;N]", " LeftAnti Join: t1.t1_id = t2.t2_id Filter: t1.t1_id > UInt32(11) [t1_id:UInt32;N, t1_name:Utf8;N]", " TableScan: t1 projection=[t1_id, t1_name] [t1_id:UInt32;N, t1_name:Utf8;N]", " Projection: t2.t2_id [t2_id:UInt32;N]", " TableScan: t2 projection=[t2_id] [t2_id:UInt32;N]", ]; ``` -- 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]
