Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/catalog: add root test and fix doc #806

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
wangrunji0408 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading