Home > Software design >  Apache AGE - How to delete a label table properly?
Apache AGE - How to delete a label table properly?

Time:01-31

From AGE's source code, there is a function from the label_commands.c file which is called drop_label and I suppose that it deletes the table containing the label name. However, when I delete a vertex that is the only vertex of a label, it's table still appears at ag_catalog.ag_label (which stores all the available labels present in the graphs).

Here is the ag_catalog.ag_label table before deleting the only vertex from demo."Comic":

demo=# SELECT * FROM ag_catalog.ag_label;
       name       | graph | id | kind |       relation        |        seq_name
------------------ ------- ---- ------ ----------------------- -------------------------
 _ag_label_vertex | 16940 |  1 | v    | demo._ag_label_vertex | _ag_label_vertex_id_seq
 _ag_label_edge   | 16940 |  2 | e    | demo._ag_label_edge   | _ag_label_edge_id_seq
 Person           | 16940 |  3 | v    | demo."Person"         | Person_id_seq
 Book             | 16940 |  4 | v    | demo."Book"           | Book_id_seq
 Comic            | 16940 |  5 | v    | demo."Comic"          | Comic_id_seq
 Author           | 16940 |  6 | v    | demo."Author"         | Author_id_seq
 AUTHOR_OF        | 16940 |  7 | e    | demo."AUTHOR_OF"      | AUTHOR_OF_id_seq
 Store            | 16940 |  8 | v    | demo."Store"          | Store_id_seq
(8 rows)

Deleting the vertex:

demo=# SELECT * FROM cypher('demo', $$
demo$# MATCH (v:Comic)
demo$# DETACH DELETE v
demo$# $$) as (v agtype);

Showing the contents of demo."Comic" afterwards:

demo=# SELECT * FROM demo."Comic";
 id | properties
---- ------------
(0 rows)

Since all the vertices of this label were removed, shouldn't this label also have been deleted and not even show this table? If not, how can I delete this label with cypher commands?

CodePudding user response:

You can use the drop label function.

SELECT drop_label('graph_name','label_name');

Do note that this is not a cypher command, rather an AGE-specific function.

  • Related