MCPcopy Create free account
hub / github.com/apache/paimon-rust / test_table_operations

Function test_table_operations

crates/paimon/src/catalog/filesystem.rs:515–569  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

513
514 #[tokio::test]
515 async fn test_table_operations() {
516 let (_temp_dir, catalog) = create_test_catalog();
517 catalog
518 .create_database("db1", false, HashMap::new())
519 .await
520 .unwrap();
521
522 // create and list tables
523 let schema = testing_schema();
524 catalog
525 .create_table(&Identifier::new("db1", "table1"), schema.clone(), false)
526 .await
527 .unwrap();
528 catalog
529 .create_table(&Identifier::new("db1", "table2"), schema, false)
530 .await
531 .unwrap();
532 let tables = catalog.list_tables("db1").await.unwrap();
533 assert_eq!(tables.len(), 2);
534 assert!(tables.contains(&"table1".to_string()));
535 assert!(tables.contains(&"table2".to_string()));
536
537 // get_table and check schema
538 let schema_with_name = Schema::builder()
539 .column(
540 "id",
541 crate::spec::DataType::Int(crate::spec::IntType::new()),
542 )
543 .column(
544 "name",
545 crate::spec::DataType::VarChar(crate::spec::VarCharType::string_type()),
546 )
547 .build()
548 .unwrap();
549 catalog
550 .create_table(&Identifier::new("db1", "table3"), schema_with_name, false)
551 .await
552 .unwrap();
553 let table = catalog
554 .get_table(&Identifier::new("db1", "table3"))
555 .await
556 .unwrap();
557 let table_schema = table.schema();
558 assert_eq!(table_schema.id(), 0);
559 assert_eq!(table_schema.fields().len(), 2);
560
561 // drop table
562 catalog
563 .drop_table(&Identifier::new("db1", "table1"), false)
564 .await
565 .unwrap();
566 let tables = catalog.list_tables("db1").await.unwrap();
567 assert_eq!(tables.len(), 2);
568 assert!(!tables.contains(&"table1".to_string()));
569 }
570
571 #[tokio::test]
572 async fn test_list_partitions_default_table_not_found_errors() {

Callers

nothing calls this directly

Calls 10

create_test_catalogFunction · 0.85
testing_schemaFunction · 0.85
columnMethod · 0.80
create_databaseMethod · 0.45
create_tableMethod · 0.45
list_tablesMethod · 0.45
buildMethod · 0.45
get_tableMethod · 0.45
schemaMethod · 0.45
drop_tableMethod · 0.45

Tested by

no test coverage detected