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

Function expr_is_restrict_null_predicate

datafusion/optimizer/src/utils.rs:200–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198
199 #[test]
200 fn expr_is_restrict_null_predicate() -> Result<()> {
201 let test_cases = vec![
202 // a
203 (col("a"), true),
204 // a IS NULL
205 (is_null(col("a")), false),
206 // a IS NOT NULL
207 (Expr::IsNotNull(Box::new(col("a"))), true),
208 // a = NULL
209 (
210 binary_expr(
211 col("a"),
212 Operator::Eq,
213 Expr::Literal(ScalarValue::Null, None),
214 ),
215 true,
216 ),
217 // a > 8
218 (binary_expr(col("a"), Operator::Gt, lit(8i64)), true),
219 // a <= 8
220 (binary_expr(col("a"), Operator::LtEq, lit(8i32)), true),
221 // CASE a WHEN 1 THEN true WHEN 0 THEN false ELSE NULL END
222 (
223 case(col("a"))
224 .when(lit(1i64), lit(true))
225 .when(lit(0i64), lit(false))
226 .otherwise(lit(ScalarValue::Null))?,
227 true,
228 ),
229 // CASE a WHEN 1 THEN true ELSE false END
230 (
231 case(col("a"))
232 .when(lit(1i64), lit(true))
233 .otherwise(lit(false))?,
234 true,
235 ),
236 // CASE a WHEN 0 THEN false ELSE true END
237 (
238 case(col("a"))
239 .when(lit(0i64), lit(false))
240 .otherwise(lit(true))?,
241 false,
242 ),
243 // (CASE a WHEN 0 THEN false ELSE true END) OR false
244 (
245 binary_expr(
246 case(col("a"))
247 .when(lit(0i64), lit(false))
248 .otherwise(lit(true))?,
249 Operator::Or,
250 lit(false),
251 ),
252 false,
253 ),
254 // (CASE a WHEN 0 THEN true ELSE false END) OR false
255 (
256 binary_expr(
257 case(col("a"))

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…