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?

0

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

After looking in the sql files the function is called in your problem might me that you are not passing the label name in cypher form. try this query instead of the one your are executing.

SELECT agtype_build_vertex(1,$$vertex$$,NULL);

I hope this helps.

Comments

-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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.