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

Function test_fill_null_all_columns

datafusion/core/tests/dataframe/mod.rs:6486–6527  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6484
6485#[tokio::test]
6486async fn test_fill_null_all_columns() -> Result<()> {
6487 let df = create_null_table().await?;
6488
6489 // Use fill_null to replace nulls on all columns.
6490 // Only column "b" will be replaced since ScalarValue::Utf8(Some("default".to_string()))
6491 // can be cast to Utf8.
6492 let df_filled =
6493 df.fill_null(ScalarValue::Utf8(Some("default".to_string())), vec![])?;
6494
6495 let results = df_filled.clone().collect().await?;
6496
6497 assert_snapshot!(
6498 batches_to_sort_string(&results),
6499 @r"
6500 +---+---------+
6501 | a | b |
6502 +---+---------+
6503 | | default |
6504 | 1 | x |
6505 | 3 | z |
6506 +---+---------+
6507 "
6508 );
6509
6510 // Fill column "a" null values with a value that cannot be cast to Int32.
6511 let df_filled = df_filled.fill_null(ScalarValue::Int32(Some(0)), vec![])?;
6512
6513 let results = df_filled.collect().await?;
6514 assert_snapshot!(
6515 batches_to_sort_string(&results),
6516 @r"
6517 +---+---------+
6518 | a | b |
6519 +---+---------+
6520 | 0 | default |
6521 | 1 | x |
6522 | 3 | z |
6523 +---+---------+
6524 "
6525 );
6526 Ok(())
6527}
6528
6529#[tokio::test]
6530async fn test_insert_into_casting_support() -> Result<()> {

Callers

nothing calls this directly

Calls 5

create_null_tableFunction · 0.85
fill_nullMethod · 0.80
collectMethod · 0.80
to_stringMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…