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

Function with_column_name

datafusion/core/tests/dataframe/mod.rs:2372–2401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2370
2371#[tokio::test]
2372async fn with_column_name() -> Result<()> {
2373 // define data with a column name that has a "." in it:
2374 let array: Int32Array = [1, 10].into_iter().collect();
2375 let batch = RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)])?;
2376
2377 let ctx = SessionContext::new();
2378 ctx.register_batch("t", batch)?;
2379
2380 let df = ctx
2381 .table("t")
2382 .await?
2383 // try and create a column with a '.' in it
2384 .with_column("f.c2", lit("hello"))?;
2385
2386 let df_results = df.collect().await?;
2387
2388 assert_snapshot!(
2389 batches_to_sort_string(&df_results),
2390 @r"
2391 +------+-------+
2392 | f.c1 | f.c2 |
2393 +------+-------+
2394 | 1 | hello |
2395 | 10 | hello |
2396 +------+-------+
2397 "
2398 );
2399
2400 Ok(())
2401}
2402
2403#[tokio::test]
2404async fn test_cache_mismatch() -> Result<()> {

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
collectMethod · 0.80
with_columnMethod · 0.80
litFunction · 0.50
into_iterMethod · 0.45
register_batchMethod · 0.45
tableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…