| 216 | |
| 217 | #[tokio::test] |
| 218 | async 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] |
| 248 | async fn test_nvl2() -> Result<()> { |