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

Function test_resolve_positions_to_exprs

datafusion/sql/src/utils.rs:1052–1078  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1050
1051 #[test]
1052 fn test_resolve_positions_to_exprs() -> Result<()> {
1053 let select_exprs = vec![col("c1"), col("c2"), count(lit(1))];
1054
1055 // Assert 1 resolved as first column in select list
1056 let resolved = resolve_positions_to_exprs(lit(1i64), &select_exprs)?;
1057 assert_eq!(resolved, col("c1"));
1058
1059 // Assert error if index out of select clause bounds
1060 let resolved = resolve_positions_to_exprs(lit(-1i64), &select_exprs);
1061 assert!(resolved.is_err_and(|e| e.message().contains(
1062 "Cannot find column with position -1 in SELECT clause. Valid columns: 1 to 3"
1063 )));
1064
1065 let resolved = resolve_positions_to_exprs(lit(5i64), &select_exprs);
1066 assert!(resolved.is_err_and(|e| e.message().contains(
1067 "Cannot find column with position 5 in SELECT clause. Valid columns: 1 to 3"
1068 )));
1069
1070 // Assert expression returned as-is
1071 let resolved = resolve_positions_to_exprs(lit("text"), &select_exprs)?;
1072 assert_eq!(resolved, lit("text"));
1073
1074 let resolved = resolve_positions_to_exprs(col("fake"), &select_exprs)?;
1075 assert_eq!(resolved, col("fake"));
1076
1077 Ok(())
1078 }
1079}

Callers

nothing calls this directly

Calls 3

litFunction · 0.50
colFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…