2

From the psql terminal, I'm trying to use an Apache AGE builtin function with the following signature:

Datum _agtype_build_vertex(PG_FUNCTION_ARGS)

the function is located here: https://github.com/apache/age/blob/a84c0392ffcfe63ecbc70ca4b45f1f0c3de28f7d/src/backend/utils/adt/agtype.c#L2167

but I wasn't able to call it with the proper arguments.

I tried the following commands on psql terminal (the error messages are shown below the commands):

test=# select _agtype_build_vertex(1,"vertex", "{}");
-- "ERROR:  column "vertex" does not exist at character 22"

test=# SELECT agtype_build_vertex(1,"_ag_label_vertex","{}");
ERROR:  column "_ag_label_vertex" does not exist at character 30

test=# SELECT * FROM agtype_build_vertex(1,"_ag_label_vertex","{}");
ERROR:  column "_ag_label_vertex" does not exist at character 37

What would be the proper way to call this function?

Marco Souza
  • 296
  • 7

2 Answers2

2

These are some of the correct ways of calling the function from psql terminal and also age-viewer.

--Basic Vertex Creation
SELECT _agtype_build_vertex('1'::graphid, $$label_name$$, agtype_build_map());
SELECT _agtype_build_vertex('1'::graphid, $$label$$, agtype_build_map('id', 2));

--Null properties
SELECT _agtype_build_vertex('1'::graphid, $$label_name$$, NULL);

This SQL script has many more examples of calling _agtype_build_vertex and other functions.

abhishek2046
  • 312
  • 1
  • 11
-1

agtype_build_vertex function to build a vertex using the agtype data type. The function takes two parameters: the vertex label and a JSON object representing the properties of the vertex.

SELECT _agtype_build_vertex('Timetable', '{"subject": "English", "duration": 3}');

This will create a vertex with the label "person" and the properties "name" and "age" in the current database.