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

Function create_variable_expr

datafusion/core/src/execution/context/mod.rs:2403–2429  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2401
2402 #[tokio::test]
2403 async fn create_variable_expr() -> Result<()> {
2404 let tmp_dir = TempDir::new()?;
2405 let partition_count = 4;
2406 let ctx = create_ctx(&tmp_dir, partition_count).await?;
2407
2408 let variable_provider = test::variable::SystemVar::new();
2409 ctx.register_variable(VarType::System, Arc::new(variable_provider));
2410 let variable_provider = test::variable::UserDefinedVar::new();
2411 ctx.register_variable(VarType::UserDefined, Arc::new(variable_provider));
2412
2413 let provider = test::create_table_dual();
2414 ctx.register_table("dual", provider)?;
2415
2416 let results =
2417 plan_and_collect(&ctx, "SELECT @@version, @name, @integer + 1 FROM dual")
2418 .await?;
2419
2420 assert_snapshot!(batches_to_string(&results), @r"
2421 +----------------------+------------------------+---------------------+
2422 | @@version | @name | @integer + Int64(1) |
2423 +----------------------+------------------------+---------------------+
2424 | system-var-@@version | user-defined-var-@name | 42 |
2425 +----------------------+------------------------+---------------------+
2426 ");
2427
2428 Ok(())
2429 }
2430
2431 #[tokio::test]
2432 async fn create_variable_err() -> Result<()> {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
create_ctxFunction · 0.85
create_table_dualFunction · 0.85
register_variableMethod · 0.80
plan_and_collectFunction · 0.50
register_tableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…