Skip to content

Commit

Permalink
chore/catalog: add root test and fix doc (#806)
Browse files Browse the repository at this point in the history
* chore/catalog: add root test and fix doc

Signed-off-by: caicancai <[email protected]>

* chore/catalog: add root test and fix doc

Signed-off-by: caicancai <[email protected]>

* chore/catalog: add root test and fix doc

Signed-off-by: caicancai <[email protected]>

---------

Signed-off-by: caicancai <[email protected]>
  • Loading branch information
caicancai authored Nov 15, 2023
1 parent 3ea03ac commit 73b2c79
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/03-architecture-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ After that, the table will be created, and the table information will be stored

```plain
> \dt
| 0 | postgres | 0 | postgres | 18 | t |
| 0 | postgres | 0 | users |
| 0 | postgres | 1 | t |
| 1 | pg_catalog | 0 | contributors |
```

## Parser
Expand Down
25 changes: 25 additions & 0 deletions src/catalog/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,28 @@ fn split_name(name: &str) -> Option<(&str, &str)> {
_ => None,
}
}

#[cfg(test)]
mod tests {
use std::sync::Arc;

use super::*;

#[test]
fn test_root_catalog() {
let catalog = Arc::new(RootCatalog::new());
let schema_catalog1 = catalog.get_schema_by_id(0).unwrap();
assert_eq!(schema_catalog1.id(), 0);
assert_eq!(schema_catalog1.name(), DEFAULT_SCHEMA_NAME);

let schema_catalog2 = catalog.get_schema_by_name(DEFAULT_SCHEMA_NAME).unwrap();
assert_eq!(schema_catalog1.id(), schema_catalog2.id());
assert_eq!(schema_catalog1.name(), schema_catalog2.name());

let col = ColumnCatalog::new(0, DataTypeKind::Int32.not_null().to_column("a".into()));
let table_id = catalog
.add_table(0, "t".into(), vec![col], false, vec![])
.unwrap();
assert_eq!(table_id, 0);
}
}

0 comments on commit 73b2c79

Please sign in to comment.