Skip to content

Commit 0043651

Browse files
committed
Handle missing root_dir gracefully.
1 parent 14c8758 commit 0043651

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

cpp/deeplake_pg/table_storage.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ void table_storage::save_table_metadata(const pg::table_data& table_data)
236236
}
237237
return root;
238238
}();
239+
if (root_dir.empty()) {
240+
return;
241+
}
239242
auto creds = session_credentials::get_credentials();
240243
pg::dl_catalog::ensure_catalog(root_dir, creds);
241244

@@ -292,8 +295,8 @@ void table_storage::load_table_metadata()
292295
}();
293296
auto creds = session_credentials::get_credentials();
294297

295-
// Stateless catalog sync (only when enabled)
296-
if (pg::stateless_enabled) {
298+
// Stateless catalog sync (only when enabled and root_dir is configured)
299+
if (pg::stateless_enabled && !root_dir.empty()) {
297300
// Fast path: if already loaded, just check version without ensure_catalog
298301
if (tables_loaded_) {
299302
const auto current_version = pg::dl_catalog::get_catalog_version(root_dir, creds);
@@ -534,7 +537,7 @@ void table_storage::load_table_metadata()
534537
}
535538
try {
536539
// Seed the DL catalog with legacy metadata (only when stateless is enabled).
537-
if (pg::stateless_enabled) {
540+
if (pg::stateless_enabled && !root_dir.empty()) {
538541
auto [schema_name, simple_table_name] = split_table_name(table_name);
539542
pg::dl_catalog::table_meta meta;
540543
meta.table_id = schema_name + "." + simple_table_name;
@@ -580,7 +583,7 @@ void table_storage::load_table_metadata()
580583
base::log_channel::generic, "Failed to delete invalid table metadata for table_oid: {}", invalid_oid);
581584
}
582585
}
583-
if (catalog_seeded && pg::stateless_enabled) {
586+
if (catalog_seeded && pg::stateless_enabled && !root_dir.empty()) {
584587
pg::dl_catalog::bump_catalog_version(root_dir, session_credentials::get_credentials());
585588
catalog_version_ = pg::dl_catalog::get_catalog_version(root_dir, session_credentials::get_credentials());
586589
}
@@ -991,17 +994,19 @@ void table_storage::drop_table(const std::string& table_name)
991994
}
992995
return root;
993996
}();
994-
pg::dl_catalog::ensure_catalog(root_dir, creds);
995-
auto [schema_name, simple_table_name] = split_table_name(table_name);
996-
pg::dl_catalog::table_meta meta;
997-
meta.table_id = schema_name + "." + simple_table_name;
998-
meta.schema_name = schema_name;
999-
meta.table_name = simple_table_name;
1000-
meta.dataset_path = table_data.get_dataset_path().url();
1001-
meta.state = "dropping";
1002-
pg::dl_catalog::upsert_table(root_dir, creds, meta);
1003-
pg::dl_catalog::bump_catalog_version(root_dir, session_credentials::get_credentials());
1004-
catalog_version_ = pg::dl_catalog::get_catalog_version(root_dir, session_credentials::get_credentials());
997+
if (!root_dir.empty()) {
998+
pg::dl_catalog::ensure_catalog(root_dir, creds);
999+
auto [schema_name, simple_table_name] = split_table_name(table_name);
1000+
pg::dl_catalog::table_meta meta;
1001+
meta.table_id = schema_name + "." + simple_table_name;
1002+
meta.schema_name = schema_name;
1003+
meta.table_name = simple_table_name;
1004+
meta.dataset_path = table_data.get_dataset_path().url();
1005+
meta.state = "dropping";
1006+
pg::dl_catalog::upsert_table(root_dir, creds, meta);
1007+
pg::dl_catalog::bump_catalog_version(root_dir, session_credentials::get_credentials());
1008+
catalog_version_ = pg::dl_catalog::get_catalog_version(root_dir, session_credentials::get_credentials());
1009+
}
10051010
}
10061011

10071012
try {

0 commit comments

Comments
 (0)