()
| 1445 | |
| 1446 | #[test] |
| 1447 | fn test_table_scan_alias() -> Result<()> { |
| 1448 | let schema = Schema::new(vec![ |
| 1449 | Field::new("id", DataType::Utf8, false), |
| 1450 | Field::new("age", DataType::Utf8, false), |
| 1451 | ]); |
| 1452 | |
| 1453 | let plan = table_scan(Some("t1"), &schema, None)? |
| 1454 | .project(vec![col("id")])? |
| 1455 | .alias("a")? |
| 1456 | .build()?; |
| 1457 | let sql = plan_to_sql(&plan)?; |
| 1458 | assert_snapshot!( |
| 1459 | sql, |
| 1460 | @"SELECT * FROM (SELECT t1.id FROM t1) AS a" |
| 1461 | ); |
| 1462 | |
| 1463 | let plan = table_scan(Some("t1"), &schema, None)? |
| 1464 | .project(vec![col("id")])? |
| 1465 | .alias("a")? |
| 1466 | .build()?; |
| 1467 | |
| 1468 | let sql = plan_to_sql(&plan)?; |
| 1469 | assert_snapshot!( |
| 1470 | sql, |
| 1471 | @"SELECT * FROM (SELECT t1.id FROM t1) AS a" |
| 1472 | ); |
| 1473 | |
| 1474 | let plan = table_scan(Some("t1"), &schema, None)? |
| 1475 | .filter(col("id").gt(lit(5)))? |
| 1476 | .project(vec![col("id")])? |
| 1477 | .alias("a")? |
| 1478 | .build()?; |
| 1479 | let sql = plan_to_sql(&plan)?; |
| 1480 | assert_snapshot!( |
| 1481 | sql, |
| 1482 | @"SELECT * FROM (SELECT t1.id FROM t1 WHERE (t1.id > 5)) AS a" |
| 1483 | ); |
| 1484 | |
| 1485 | let table_scan_with_two_filter = table_scan_with_filters( |
| 1486 | Some("t1"), |
| 1487 | &schema, |
| 1488 | None, |
| 1489 | vec![col("id").gt(lit(1)), col("age").lt(lit(2))], |
| 1490 | )? |
| 1491 | .project(vec![col("id")])? |
| 1492 | .alias("a")? |
| 1493 | .build()?; |
| 1494 | let table_scan_with_two_filter = plan_to_sql(&table_scan_with_two_filter)?; |
| 1495 | assert_snapshot!( |
| 1496 | table_scan_with_two_filter, |
| 1497 | @"SELECT a.id FROM t1 AS a WHERE ((a.id > 1) AND (a.age < 2))" |
| 1498 | ); |
| 1499 | |
| 1500 | let table_scan_with_fetch = |
| 1501 | table_scan_with_filter_and_fetch(Some("t1"), &schema, None, vec![], Some(10))? |
| 1502 | .project(vec![col("id")])? |
| 1503 | .alias("a")? |
| 1504 | .build()?; |
nothing calls this directly
no test coverage detected
searching dependent graphs…