MCPcopy Create free account
hub / github.com/apache/datafusion / where_in_subquery

Function where_in_subquery

datafusion-examples/examples/dataframe/dataframe.rs:297–318  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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;
297async 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;

Callers 1

dataframe_exampleFunction · 0.85

Calls 13

in_subqueryFunction · 0.85
newFunction · 0.85
showMethod · 0.80
into_unoptimized_planMethod · 0.80
colFunction · 0.50
litFunction · 0.50
limitMethod · 0.45
selectMethod · 0.45
filterMethod · 0.45
tableMethod · 0.45
aggregateMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…