alamb commented on code in PR #19319:
URL: https://github.com/apache/datafusion/pull/19319#discussion_r2635744438
##########
datafusion-examples/examples/dataframe/dataframe.rs:
##########
@@ -266,77 +268,79 @@ async fn write_out(ctx: &SessionContext) -> Result<()> {
}
/// Use the DataFrame API to execute the following subquery:
-/// select c1,c2 from t1 where (select avg(t2.c2) from t2 where t1.c1 =
t2.c1)>0 limit 3;
+/// select car, speed from t1 where (select avg(t2.speed) from t2 where t1.car
= t2.car) > 0 limit 3;
async fn where_scalar_subquery(ctx: &SessionContext) -> Result<()> {
ctx.table("t1")
.await?
.filter(
scalar_subquery(Arc::new(
ctx.table("t2")
.await?
- .filter(out_ref_col(DataType::Utf8,
"t1.c1").eq(col("t2.c1")))?
- .aggregate(vec![], vec![avg(col("t2.c2"))])?
- .select(vec![avg(col("t2.c2"))])?
+ .filter(out_ref_col(DataType::Utf8,
"t1.car").eq(col("t2.car")))?
+ .aggregate(vec![], vec![avg(col("t2.speed"))])?
+ .select(vec![avg(col("t2.speed"))])?
.into_unoptimized_plan(),
))
- .gt(lit(0u8)),
+ .gt(lit(0.0)),
)?
- .select(vec![col("t1.c1"), col("t1.c2")])?
+ .select(vec![col("t1.car"), col("t1.speed")])?
.limit(0, Some(3))?
.show()
.await?;
Ok(())
}
/// Use the DataFrame API to execute the following subquery:
-/// select t1.c1, t1.c2 from t1 where t1.c2 in (select max(t2.c2) from t2
where t2.c1 > 0 ) limit 3;
+/// select t1.car, t1.speed from t1 where t1.speed in (select max(t2.speed)
from t2 where t2.car = 'red') limit 3;
Review Comment:
i actually think this is much more readable now
--
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]