|
18 | 18 | use async_trait::async_trait; |
19 | 19 | use sqlx::{ |
20 | 20 | any::{install_default_drivers, AnyPoolOptions, AnyRow}, |
21 | | - Any, AnyPool, Column, Execute, Row, TypeInfo, |
| 21 | + AnyPool, Row, |
22 | 22 | }; |
23 | 23 | use std::borrow::Cow; |
24 | 24 | use std::collections::HashMap; |
@@ -235,15 +235,13 @@ fn query_map(row: &AnyRow) -> std::result::Result<TableRef, sqlx::Error> { |
235 | 235 | } |
236 | 236 |
|
237 | 237 | #[derive(Debug)] |
238 | | -struct NamespaceRef { |
239 | | - namespace_name: String, |
| 238 | +struct NamespacePropRef { |
240 | 239 | namespace_prop_key: String, |
241 | 240 | namespace_prop_value: String, |
242 | 241 | } |
243 | 242 |
|
244 | | -fn query_map_namespace(row: &AnyRow) -> std::result::Result<NamespaceRef, sqlx::Error> { |
245 | | - Ok(NamespaceRef { |
246 | | - namespace_name: row.try_get(0)?, |
| 243 | +fn query_map_namespace(row: &AnyRow) -> std::result::Result<NamespacePropRef, sqlx::Error> { |
| 244 | + Ok(NamespacePropRef { |
247 | 245 | namespace_prop_key: row.try_get(1)?, |
248 | 246 | namespace_prop_value: row.try_get(2)?, |
249 | 247 | }) |
@@ -484,8 +482,21 @@ impl Catalog for SqlCatalog { |
484 | 482 | Ok(iter.next().is_some()) |
485 | 483 | } |
486 | 484 |
|
487 | | - async fn drop_table(&self, _identifier: &TableIdent) -> Result<()> { |
488 | | - todo!() |
| 485 | + async fn drop_table(&self, identifier: &TableIdent) -> Result<()> { |
| 486 | + let catalog_name = self.name.clone(); |
| 487 | + let namespace = identifier.namespace().encode_in_url(); |
| 488 | + let name = identifier.name.to_string(); |
| 489 | + |
| 490 | + self.execute_statement( |
| 491 | + &format!( |
| 492 | + "delete from {} where {} = ? and {} = ? and {} = ?", |
| 493 | + CATALOG_TABLE_VIEW_NAME, CATALOG_NAME, TABLE_NAMESPACE, TABLE_NAME |
| 494 | + ), |
| 495 | + vec![Some(&catalog_name), Some(&namespace), Some(&name)], |
| 496 | + ) |
| 497 | + .await?; |
| 498 | + |
| 499 | + Ok(()) |
489 | 500 | } |
490 | 501 |
|
491 | 502 | async fn load_table(&self, identifier: &TableIdent) -> Result<Table> { |
@@ -654,6 +665,10 @@ impl Catalog for SqlCatalog { |
654 | 665 |
|
655 | 666 | async fn update_table(&self, _commit: TableCommit) -> Result<Table> { |
656 | 667 | todo!() |
| 668 | + // let table_ident = commit.identifier(); |
| 669 | + // let requirements = commit.take_requirements(); |
| 670 | + // let updates = commit.take_updates(); |
| 671 | + // let table = self.load_table(table_ident).await?; |
657 | 672 | } |
658 | 673 | } |
659 | 674 |
|
|
0 commit comments