Skip to content

Commit

Permalink
store: update namespace handling in table creation and index loading
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyasmohd committed Mar 5, 2025
1 parent 086104f commit 0b1c109
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion store/postgres/src/relational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ impl Table {
pub fn new_like(&self, namespace: &Namespace, name: &SqlName) -> Arc<Table> {
let other = Table {
object: self.object.clone(),
nsp: self.nsp.clone(),
nsp: namespace.clone(),
name: name.clone(),
qualified_name: SqlName::qualified_name(namespace, name),
columns: self.columns.clone(),
Expand Down
8 changes: 1 addition & 7 deletions store/postgres/src/relational/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,7 @@ impl Table {
if index_def.is_some() && ENV_VARS.postpone_attribute_index_creation {
let arr = index_def
.unwrap()
.indexes_for_table(
&catalog.site.namespace,
&self.name.to_string(),
&self,
false,
false,
)
.indexes_for_table(&self.nsp, &self.name.to_string(), &self, false, false)
.map_err(|_| fmt::Error)?;
for (_, sql) in arr {
writeln!(out, "{};", sql).expect("properly formated index statements")
Expand Down
2 changes: 1 addition & 1 deletion store/postgres/src/relational/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ impl CreateIndex {
}
}

fn with_nsp(&self, nsp2: String) -> Result<Self, Error> {
pub fn with_nsp(&self, nsp2: String) -> Result<Self, Error> {
let s = self.clone();
match s {
CreateIndex::Unknown { defn: _ } => Err(anyhow!("Failed to parse the index")),
Expand Down
12 changes: 9 additions & 3 deletions store/postgres/src/relational/prune.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fmt::Write, sync::Arc, time::Instant};
use std::{collections::HashMap, fmt::Write, sync::Arc};

use diesel::{
connection::SimpleConnection,
Expand All @@ -23,7 +23,10 @@ use crate::{
vid_batcher::{VidBatcher, VidRange},
};

use super::{Catalog, Layout, Namespace};
use super::{
index::{load_indexes_from_table, CreateIndex, IndexList},
Catalog, Layout, Namespace,
};

/// Utility to copy relevant data out of a source table and into a new
/// destination table and replace the source table with the destination
Expand Down Expand Up @@ -59,7 +62,10 @@ impl TablePair {
let mut list = IndexList {
indexes: HashMap::new(),
};
let indexes = load_indexes_from_table(conn, &src, src_nsp.as_str())?;
let indexes = load_indexes_from_table(conn, &src, src_nsp.as_str())?
.into_iter()
.map(|index| index.with_nsp(dst_nsp.to_string()))
.collect::<Result<Vec<CreateIndex>, _>>()?;
list.indexes.insert(src.name.to_string(), indexes);

// In case of pruning we don't do delayed creation of indexes,
Expand Down

0 comments on commit 0b1c109

Please sign in to comment.