Use the DataFrame API to execute the following subquery: select t1.car, t1.speed from t1 where t1.speed in (select max(t2.speed) from t2 where t2.car = 'red') limit 3;
(ctx: &SessionContext)
| 295 | /// Use the DataFrame API to execute the following subquery: |
| 296 | /// select t1.car, t1.speed from t1 where t1.speed in (select max(t2.speed) from t2 where t2.car = 'red') limit 3; |
| 297 | async fn where_in_subquery(ctx: &SessionContext) -> Result<()> { |
| 298 | ctx.table("t1") |
| 299 | .await? |
| 300 | .filter(in_subquery( |
| 301 | col("t1.speed"), |
| 302 | Arc::new( |
| 303 | ctx.table("t2") |
| 304 | .await? |
| 305 | .filter( |
| 306 | col("t2.car").eq(lit(ScalarValue::Utf8(Some("red".to_string())))), |
| 307 | )? |
| 308 | .aggregate(vec![], vec![max(col("t2.speed"))])? |
| 309 | .select(vec![max(col("t2.speed"))])? |
| 310 | .into_unoptimized_plan(), |
| 311 | ), |
| 312 | ))? |
| 313 | .select(vec![col("t1.car"), col("t1.speed")])? |
| 314 | .limit(0, Some(3))? |
| 315 | .show() |
| 316 | .await?; |
| 317 | Ok(()) |
| 318 | } |
| 319 | |
| 320 | /// Use the DataFrame API to execute the following subquery: |
| 321 | /// select t1.car, t1.speed from t1 where exists (select t2.speed from t2 where t1.car = t2.car) limit 3; |
no test coverage detected
searching dependent graphs…