Amr-Shams commented on issue #918:
URL: https://github.com/apache/age/issues/918#issuecomment-1546772242
> > when it comes to this large size it is better to make it automatically
by creating a function that takes the list and iterates over the edges and
specified information and the function will do the job for your but still need
to process the list before passing to the function.. like creating a list of
objects...
>
> @Amr-Shams Can you give us an example of creating the function that you
are talking about ?
```SQL
CREATE OR REPLACE FUNCTION create_multiple_edges(nodes text[][]) RETURNS
void AS $$
BEGIN
FOREACH node IN ARRAY nodes
LOOP
EXECUTE format('MATCH (a:Person {name: %L}), (b:Location {name: %L})
CREATE (a)-[:VISITED]->(b)', node[1], node[2]);
END LOOP;
END;
$$ LANGUAGE plpgsql;
```
as I mentioned you have to preprocess the text input so the mapping would be
easy
``` SQL
CREATE OR REPLACE FUNCTION merge_names_cities(names text[], cities text[])
RETURNS text[][] AS $$
DECLARE
merged text[][];
BEGIN
IF array_length(names, 1) <> array_length(cities, 1) THEN
RAISE EXCEPTION 'Input arrays must be of equal length';
END IF;
FOR i IN 1..array_length(names, 1) LOOP
merged[i][1] := names[i];
merged[i][2] := cities[i];
END LOOP;
RETURN merged;
END;
$$ LANGUAGE plpgsql;
```
in the above function, the input should be easily merged and then the output
of the above function should be passed to the edge_creation function ..
assuming the input will be mapped in this way
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]