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

Function in_list_struct

datafusion/physical-expr/src/expressions/in_list.rs:1373–1438  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1371
1372 #[test]
1373 fn in_list_struct() -> Result<()> {
1374 // Create schema with a struct column
1375 let struct_fields = Fields::from(vec![
1376 Field::new("x", DataType::Int32, false),
1377 Field::new("y", DataType::Utf8, false),
1378 ]);
1379 let schema = Schema::new(vec![Field::new(
1380 "a",
1381 DataType::Struct(struct_fields.clone()),
1382 true,
1383 )]);
1384
1385 // Create test data: array of structs
1386 let x_array = Arc::new(Int32Array::from(vec![1, 2, 3]));
1387 let y_array = Arc::new(StringArray::from(vec!["a", "b", "c"]));
1388 let struct_array =
1389 StructArray::new(struct_fields.clone(), vec![x_array, y_array], None);
1390
1391 let col_a = col("a", &schema)?;
1392 let batch =
1393 RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(struct_array)])?;
1394
1395 // Create literal structs for the IN list
1396 // Struct {x: 1, y: "a"}
1397 let struct1 = ScalarValue::Struct(Arc::new(StructArray::new(
1398 struct_fields.clone(),
1399 vec![
1400 Arc::new(Int32Array::from(vec![1])),
1401 Arc::new(StringArray::from(vec!["a"])),
1402 ],
1403 None,
1404 )));
1405
1406 // Struct {x: 3, y: "c"}
1407 let struct3 = ScalarValue::Struct(Arc::new(StructArray::new(
1408 struct_fields.clone(),
1409 vec![
1410 Arc::new(Int32Array::from(vec![3])),
1411 Arc::new(StringArray::from(vec!["c"])),
1412 ],
1413 None,
1414 )));
1415
1416 // Test: a IN ({1, "a"}, {3, "c"})
1417 let list = vec![lit(struct1.clone()), lit(struct3.clone())];
1418 in_list_raw!(
1419 batch,
1420 list.clone(),
1421 &false,
1422 vec![Some(true), Some(false), Some(true)],
1423 Arc::clone(&col_a),
1424 &schema
1425 );
1426
1427 // Test: a NOT IN ({1, "a"}, {3, "c"})
1428 in_list_raw!(
1429 batch,
1430 list,

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
colFunction · 0.70
StructClass · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…