()
| 593 | |
| 594 | #[tokio::test] |
| 595 | async fn test_insert_overwrite() { |
| 596 | use paimon::io::FileIOBuilder; |
| 597 | use paimon::spec::{DataType, IntType, Schema as PaimonSchema, TableSchema, VarCharType}; |
| 598 | |
| 599 | let file_io = FileIOBuilder::new("memory").build().unwrap(); |
| 600 | let table_path = "memory:/test_df_insert_overwrite"; |
| 601 | file_io |
| 602 | .mkdirs(&format!("{table_path}/snapshot/")) |
| 603 | .await |
| 604 | .unwrap(); |
| 605 | file_io |
| 606 | .mkdirs(&format!("{table_path}/manifest/")) |
| 607 | .await |
| 608 | .unwrap(); |
| 609 | |
| 610 | let schema = PaimonSchema::builder() |
| 611 | .column("pt", DataType::VarChar(VarCharType::string_type())) |
| 612 | .column("id", DataType::Int(IntType::new())) |
| 613 | .partition_keys(["pt"]) |
| 614 | .build() |
| 615 | .unwrap(); |
| 616 | let table_schema = TableSchema::new(0, &schema); |
| 617 | let table = paimon::table::Table::new( |
| 618 | file_io, |
| 619 | Identifier::new("default", "test_overwrite"), |
| 620 | table_path.to_string(), |
| 621 | table_schema, |
| 622 | None, |
| 623 | ); |
| 624 | |
| 625 | let provider = PaimonTableProvider::try_new(table).unwrap(); |
| 626 | let ctx = SessionContext::new(); |
| 627 | ctx.register_table("t", Arc::new(provider)).unwrap(); |
| 628 | |
| 629 | // Initial INSERT: partition "a" and "b" |
| 630 | ctx.sql("INSERT INTO t VALUES ('a', 1), ('a', 2), ('b', 3), ('b', 4)") |
| 631 | .await |
| 632 | .unwrap() |
| 633 | .collect() |
| 634 | .await |
| 635 | .unwrap(); |
| 636 | |
| 637 | // INSERT OVERWRITE with only partition "a" data |
| 638 | // Should overwrite partition "a" but leave partition "b" intact |
| 639 | ctx.sql("INSERT OVERWRITE t VALUES ('a', 10), ('a', 20)") |
| 640 | .await |
| 641 | .unwrap() |
| 642 | .collect() |
| 643 | .await |
| 644 | .unwrap(); |
| 645 | |
| 646 | // Read back |
| 647 | let batches = ctx |
| 648 | .sql("SELECT pt, id FROM t ORDER BY pt, id") |
| 649 | .await |
| 650 | .unwrap() |
| 651 | .collect() |
| 652 | .await |
nothing calls this directly
no test coverage detected