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

Function test_nvl

datafusion/core/tests/dataframe/dataframe_functions.rs:218–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216
217#[tokio::test]
218async fn test_nvl() -> Result<()> {
219 let lit_null = lit(ScalarValue::Utf8(None));
220 // nvl(CASE WHEN a = 'abcDEF' THEN NULL ELSE a END, 'TURNED_NULL')
221 let expr = nvl(
222 when(col("a").eq(lit("abcDEF")), lit_null)
223 .otherwise(col("a"))
224 .unwrap(),
225 lit("TURNED_NULL"),
226 )
227 .alias("nvl_expr");
228
229 let batches = get_batches(expr).await?;
230
231 assert_snapshot!(
232 batches_to_string(&batches),
233 @r"
234 +-------------+
235 | nvl_expr |
236 +-------------+
237 | TURNED_NULL |
238 | abc123 |
239 | CBAdef |
240 | 123AbcDef |
241 +-------------+
242 ");
243
244 Ok(())
245}
246
247#[tokio::test]
248async fn test_nvl2() -> Result<()> {

Callers

nothing calls this directly

Calls 7

whenFunction · 0.85
get_batchesFunction · 0.85
otherwiseMethod · 0.80
litFunction · 0.50
colFunction · 0.50
aliasMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…