Skip to content

Commit ac34593

Browse files
committed
test(native): cover Spark function registration in build_session_context
1 parent 5cd9bf3 commit ac34593

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎native/src/lib.rs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,3 +1331,28 @@ pub extern "system" fn Java_org_apache_datafusion_SessionContext_registerTableNa
13311331
Ok(())
13321332
})
13331333
}
1334+
1335+
#[cfg(all(test, feature = "spark"))]
1336+
mod spark_tests {
1337+
use super::*;
1338+
1339+
#[test]
1340+
fn spark_functions_register_crc32() {
1341+
let rt = Arc::new(RuntimeEnvBuilder::new().build().unwrap());
1342+
let ctx = build_session_context(SessionConfig::new(), rt, true).unwrap();
1343+
assert!(
1344+
ctx.state().scalar_functions().contains_key("crc32"),
1345+
"expected Spark crc32 to be registered when spark_functions = true"
1346+
);
1347+
}
1348+
1349+
#[test]
1350+
fn plain_context_has_no_crc32() {
1351+
let rt = Arc::new(RuntimeEnvBuilder::new().build().unwrap());
1352+
let ctx = build_session_context(SessionConfig::new(), rt, false).unwrap();
1353+
assert!(
1354+
!ctx.state().scalar_functions().contains_key("crc32"),
1355+
"crc32 must not be registered without spark_functions"
1356+
);
1357+
}
1358+
}

0 commit comments

Comments
 (0)