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

Function test_table_scan_pushdown

datafusion/sql/tests/cases/plan_to_sql.rs:1530–1735  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1528
1529#[test]
1530fn test_table_scan_pushdown() -> Result<()> {
1531 let schema = Schema::new(vec![
1532 Field::new("id", DataType::Utf8, false),
1533 Field::new("age", DataType::Utf8, false),
1534 ]);
1535 let scan_with_projection =
1536 table_scan(Some("t1"), &schema, Some(vec![0, 1]))?.build()?;
1537 let scan_with_projection = plan_to_sql(&scan_with_projection)?;
1538 assert_snapshot!(
1539 scan_with_projection,
1540 @"SELECT t1.id, t1.age FROM t1"
1541 );
1542
1543 let scan_with_projection = table_scan(Some("t1"), &schema, Some(vec![1]))?.build()?;
1544 let scan_with_projection = plan_to_sql(&scan_with_projection)?;
1545 assert_snapshot!(
1546 scan_with_projection,
1547 @"SELECT t1.age FROM t1"
1548 );
1549
1550 let scan_with_no_projection = table_scan(Some("t1"), &schema, None)?.build()?;
1551 let scan_with_no_projection = plan_to_sql(&scan_with_no_projection)?;
1552 assert_snapshot!(
1553 scan_with_no_projection,
1554 @"SELECT * FROM t1"
1555 );
1556
1557 let table_scan_with_projection_alias =
1558 table_scan(Some("t1"), &schema, Some(vec![0, 1]))?
1559 .alias("ta")?
1560 .build()?;
1561 let table_scan_with_projection_alias =
1562 plan_to_sql(&table_scan_with_projection_alias)?;
1563 assert_snapshot!(
1564 table_scan_with_projection_alias,
1565 @"SELECT ta.id, ta.age FROM t1 AS ta"
1566 );
1567
1568 let table_scan_with_projection_alias =
1569 table_scan(Some("t1"), &schema, Some(vec![1]))?
1570 .alias("ta")?
1571 .build()?;
1572 let table_scan_with_projection_alias =
1573 plan_to_sql(&table_scan_with_projection_alias)?;
1574 assert_snapshot!(
1575 table_scan_with_projection_alias,
1576 @"SELECT ta.age FROM t1 AS ta"
1577 );
1578
1579 let table_scan_with_no_projection_alias = table_scan(Some("t1"), &schema, None)?
1580 .alias("ta")?
1581 .build()?;
1582 let table_scan_with_no_projection_alias =
1583 plan_to_sql(&table_scan_with_no_projection_alias)?;
1584 assert_snapshot!(
1585 table_scan_with_no_projection_alias,
1586 @"SELECT * FROM t1 AS ta"
1587 );

Callers

nothing calls this directly

Calls 12

newFunction · 0.85
table_scanFunction · 0.85
plan_to_sqlFunction · 0.85
table_scan_with_filtersFunction · 0.85
colFunction · 0.50
litFunction · 0.50
buildMethod · 0.45
aliasMethod · 0.45
projectMethod · 0.45
filterMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…