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

Function test_nvl2

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

Source from the content-addressed store, hash-verified

246
247#[tokio::test]
248async fn test_nvl2() -> Result<()> {
249 let lit_null = lit(ScalarValue::Utf8(None));
250 // nvl2(CASE WHEN a = 'abcDEF' THEN NULL ELSE a END, 'NON_NUll', 'TURNED_NULL')
251 let expr = nvl2(
252 when(col("a").eq(lit("abcDEF")), lit_null)
253 .otherwise(col("a"))
254 .unwrap(),
255 lit("NON_NULL"),
256 lit("TURNED_NULL"),
257 )
258 .alias("nvl2_expr");
259
260 let batches = get_batches(expr).await?;
261
262 assert_snapshot!(
263 batches_to_string(&batches),
264 @r"
265 +-------------+
266 | nvl2_expr |
267 +-------------+
268 | TURNED_NULL |
269 | NON_NULL |
270 | NON_NULL |
271 | NON_NULL |
272 +-------------+
273 ");
274
275 Ok(())
276}
277
278#[tokio::test]
279async fn test_nvl2_short_circuit() -> 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…