Verified Commit b544b52a authored by Michael Usachenko's avatar Michael Usachenko Committed by GitLab
Browse files

feat(ontology): add name field to local_db edge table config

parent ad30ccef
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ settings:
      - name: ImportedSymbol
        exclude_properties: [traversal_path, commit_sha]
    edge_table:
      name: gl_edge
      columns:
        - {name: source_id, type: int64}
        - {name: source_kind, type: string}
+5 −1
Original line number Diff line number Diff line
@@ -399,8 +399,12 @@
            "edge_table": {
              "type": "object",
              "description": "Edge table schema for the local DuckDB graph.",
              "required": ["columns"],
              "required": ["name", "columns"],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Table name for the local edge table."
                },
                "columns": {
                  "type": "array",
                  "items": {
+11 −1
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ pub struct Ontology {
    /// Local entity configs keyed by entity name. Each entry lists
    /// properties to exclude from the local DuckDB table.
    pub(crate) local_entities: BTreeMap<String, Vec<String>>,
    /// Local edge table name, if declared.
    pub(crate) local_edge_table_name: Option<String>,
    /// Local edge table columns, if declared.
    pub(crate) local_edge_columns: Vec<EdgeColumn>,
}
@@ -158,6 +160,7 @@ impl Ontology {
            internal_column_prefix: "_gkg_".to_string(),
            skip_security_filter_for_tables: Vec::new(),
            local_entities: BTreeMap::new(),
            local_edge_table_name: None,
            local_edge_columns: Vec::new(),
        }
    }
@@ -590,6 +593,12 @@ impl Ontology {
        )
    }

    /// Name of the local edge table, if declared.
    #[must_use]
    pub fn local_edge_table_name(&self) -> Option<&str> {
        self.local_edge_table_name.as_deref()
    }

    /// Column definitions for the local edge table, if declared.
    #[must_use]
    pub fn local_edge_columns(&self) -> &[EdgeColumn] {
@@ -1820,8 +1829,9 @@ properties:
    }

    #[test]
    fn local_edge_columns_loaded_from_ontology() {
    fn local_edge_table_loaded_from_ontology() {
        let ontology = Ontology::load_from_dir(fixtures_dir()).expect("should load ontology");
        assert_eq!(ontology.local_edge_table_name(), Some("gl_edge"));
        let cols = ontology.local_edge_columns();
        assert!(!cols.is_empty());
        let names: Vec<&str> = cols.iter().map(|c| c.name.as_str()).collect();
+1 −0
Original line number Diff line number Diff line
@@ -300,6 +300,7 @@ pub(crate) fn load_with(reader: &impl ReadOntologyFile) -> Result<Ontology, Onto
                }
            }

            ontology.local_edge_table_name = Some(edge_table.name);
            ontology.local_edge_columns = edge_table
                .columns
                .into_iter()
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ pub(super) struct LocalSettingsYaml {

#[derive(Debug, Deserialize)]
pub(super) struct LocalEdgeTableYaml {
    pub name: String,
    pub columns: Vec<EdgeColumnYaml>,
}