mingfang commented on issue #1709: URL: https://github.com/apache/age/issues/1709#issuecomment-2033336284
My real use case is to create a graph from a SQL query and I don't know ahead of time what fields are returned. This is my function to run SQL and return Agtype ```sql -- Apache AGE load_sql CREATE OR REPLACE FUNCTION public.load_sql(query agtype) RETURNS SETOF agtype AS $$ BEGIN RETURN QUERY EXECUTE FORMAT($sql$ WITH query AS (%s) SELECT agtype_build_list(query) FROM query $sql$, query::text); END $$ LANGUAGE plpgsql VOLATILE; ``` Then in cypher is would call that function and use MERGE to create graph. ```sql SELECT * FROM cypher('movies', $$ UNWIND public.load_sql(' SELECT * FROM movies ') AS row MERGE (v:MOVIE {title: row.title}) SET v=row RETURN count(v) $$) AS (v agtype); ``` -- 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: dev-unsubscr...@age.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org