@@ -588,8 +588,8 @@ impl Catalog for SqlCatalog {
588588 & format ! (
589589 "DELETE FROM {CATALOG_TABLE_NAME}
590590 WHERE {CATALOG_FIELD_CATALOG_NAME} = ?
591- AND {CATALOG_FIELD_TABLE_NAMESPACE} = ?
592591 AND {CATALOG_FIELD_TABLE_NAME} = ?
592+ AND {CATALOG_FIELD_TABLE_NAMESPACE} = ?
593593 AND (
594594 {CATALOG_FIELD_RECORD_TYPE} = '{CATALOG_FIELD_TABLE_RECORD_TYPE}'
595595 OR {CATALOG_FIELD_RECORD_TYPE} IS NULL
@@ -1714,4 +1714,60 @@ mod tests {
17141714 format!( "Unexpected => Table {:?} already exists." , & dst_table_ident) ,
17151715 ) ;
17161716 }
1717+
1718+ #[ tokio:: test]
1719+ async fn test_drop_table_throws_error_if_table_not_exist ( ) {
1720+ let warehouse_loc = temp_path ( ) ;
1721+ let catalog = new_sql_catalog ( warehouse_loc. clone ( ) ) . await ;
1722+ let namespace_ident = NamespaceIdent :: new ( "a" . into ( ) ) ;
1723+ let table_name = "tbl1" ;
1724+ let table_ident = TableIdent :: new ( namespace_ident. clone ( ) , table_name. into ( ) ) ;
1725+ create_namespace ( & catalog, & namespace_ident) . await ;
1726+
1727+ let err = catalog
1728+ . drop_table ( & table_ident)
1729+ . await
1730+ . unwrap_err ( )
1731+ . to_string ( ) ;
1732+ assert_eq ! (
1733+ err,
1734+ "Unexpected => No such table: TableIdent { namespace: NamespaceIdent([\" a\" ]), name: \" tbl1\" }"
1735+ ) ;
1736+ }
1737+
1738+ #[ tokio:: test]
1739+ async fn test_drop_table ( ) {
1740+ let warehouse_loc = temp_path ( ) ;
1741+ let catalog = new_sql_catalog ( warehouse_loc. clone ( ) ) . await ;
1742+ let namespace_ident = NamespaceIdent :: new ( "a" . into ( ) ) ;
1743+ let table_name = "tbl1" ;
1744+ let table_ident = TableIdent :: new ( namespace_ident. clone ( ) , table_name. into ( ) ) ;
1745+ create_namespace ( & catalog, & namespace_ident) . await ;
1746+
1747+ let location = warehouse_loc. clone ( ) ;
1748+ let table_creation = TableCreation :: builder ( )
1749+ . name ( table_name. into ( ) )
1750+ . location ( location. clone ( ) )
1751+ . schema ( simple_table_schema ( ) )
1752+ . build ( ) ;
1753+
1754+ catalog
1755+ . create_table ( & namespace_ident, table_creation)
1756+ . await
1757+ . unwrap ( ) ;
1758+
1759+ let table = catalog. load_table ( & table_ident) . await . unwrap ( ) ;
1760+ assert_table_eq ( & table, & table_ident, & simple_table_schema ( ) ) ;
1761+
1762+ catalog. drop_table ( & table_ident) . await . unwrap ( ) ;
1763+ let err = catalog
1764+ . load_table ( & table_ident)
1765+ . await
1766+ . unwrap_err ( )
1767+ . to_string ( ) ;
1768+ assert_eq ! (
1769+ err,
1770+ "Unexpected => No such table: TableIdent { namespace: NamespaceIdent([\" a\" ]), name: \" tbl1\" }"
1771+ ) ;
1772+ }
17171773}
0 commit comments