blob: 8635a499b82c5d1b3fff2c2e4e0b457621bb5b8c [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
\! cp -r regress/age_load/data regress/instance/data/age_load
LOAD 'age';
SET search_path TO ag_catalog;
SELECT create_graph('agload_test_graph');
NOTICE: graph "agload_test_graph" has been created
create_graph
--------------
(1 row)
SELECT create_vlabel('agload_test_graph','Country');
NOTICE: VLabel "Country" has been created
create_vlabel
---------------
(1 row)
SELECT load_labels_from_file('agload_test_graph', 'Country',
'age_load/countries.csv');
load_labels_from_file
-----------------------
(1 row)
SELECT create_vlabel('agload_test_graph','City');
NOTICE: VLabel "City" has been created
create_vlabel
---------------
(1 row)
SELECT load_labels_from_file('agload_test_graph', 'City',
'age_load/cities.csv');
load_labels_from_file
-----------------------
(1 row)
SELECT create_elabel('agload_test_graph','has_city');
NOTICE: ELabel "has_city" has been created
create_elabel
---------------
(1 row)
SELECT load_edges_from_file('agload_test_graph', 'has_city',
'age_load/edges.csv');
load_edges_from_file
----------------------
(1 row)
SELECT table_catalog, table_schema, lower(table_name) as table_name, table_type
FROM information_schema.tables
WHERE table_schema = 'agload_test_graph' ORDER BY table_name ASC;
table_catalog | table_schema | table_name | table_type
--------------------+-------------------+------------------+------------
contrib_regression | agload_test_graph | _ag_label_edge | BASE TABLE
contrib_regression | agload_test_graph | _ag_label_vertex | BASE TABLE
contrib_regression | agload_test_graph | city | BASE TABLE
contrib_regression | agload_test_graph | country | BASE TABLE
contrib_regression | agload_test_graph | has_city | BASE TABLE
(5 rows)
SELECT COUNT(*) FROM agload_test_graph."Country";
count
-------
53
(1 row)
SELECT COUNT(*) FROM agload_test_graph."City";
count
-------
72485
(1 row)
SELECT COUNT(*) FROM agload_test_graph."has_city";
count
-------
72485
(1 row)
SELECT COUNT(*) FROM cypher('agload_test_graph', $$MATCH(n) RETURN n$$) as (n agtype);
count
-------
72538
(1 row)
SELECT COUNT(*) FROM cypher('agload_test_graph', $$MATCH (a)-[e]->(b) RETURN e$$) as (n agtype);
count
-------
72485
(1 row)
SELECT create_vlabel('agload_test_graph','Country2');
NOTICE: VLabel "Country2" has been created
create_vlabel
---------------
(1 row)
SELECT load_labels_from_file('agload_test_graph', 'Country2',
'age_load/countries.csv', false);
load_labels_from_file
-----------------------
(1 row)
SELECT create_vlabel('agload_test_graph','City2');
NOTICE: VLabel "City2" has been created
create_vlabel
---------------
(1 row)
SELECT load_labels_from_file('agload_test_graph', 'City2',
'age_load/cities.csv', false);
load_labels_from_file
-----------------------
(1 row)
SELECT COUNT(*) FROM agload_test_graph."Country2";
count
-------
53
(1 row)
SELECT COUNT(*) FROM agload_test_graph."City2";
count
-------
72485
(1 row)
SELECT id FROM agload_test_graph."Country" LIMIT 10;
id
-----------------
844424930131970
844424930131971
844424930131974
844424930131983
844424930131989
844424930131990
844424930131996
844424930132002
844424930132023
844424930132025
(10 rows)
SELECT id FROM agload_test_graph."Country2" LIMIT 10;
id
------------------
1688849860263937
1688849860263938
1688849860263939
1688849860263940
1688849860263941
1688849860263942
1688849860263943
1688849860263944
1688849860263945
1688849860263946
(10 rows)
SELECT * FROM cypher('agload_test_graph', $$MATCH(n:Country {iso2 : 'BE'})
RETURN id(n), n.name, n.iso2 $$) as ("id(n)" agtype, "n.name" agtype, "n.iso2" agtype);
id(n) | n.name | n.iso2
-----------------+-----------+--------
844424930131990 | "Belgium" | "BE"
(1 row)
SELECT * FROM cypher('agload_test_graph', $$MATCH(n:Country2 {iso2 : 'BE'})
RETURN id(n), n.name, n.iso2 $$) as ("id(n)" agtype, "n.name" agtype, "n.iso2" agtype);
id(n) | n.name | n.iso2
------------------+-----------+--------
1688849860263942 | "Belgium" | "BE"
(1 row)
SELECT * FROM cypher('agload_test_graph', $$MATCH(n:Country {iso2 : 'AT'})
RETURN id(n), n.name, n.iso2 $$) as ("id(n)" agtype, "n.name" agtype, "n.iso2" agtype);
id(n) | n.name | n.iso2
-----------------+-----------+--------
844424930131983 | "Austria" | "AT"
(1 row)
SELECT * FROM cypher('agload_test_graph', $$MATCH(n:Country2 {iso2 : 'AT'})
RETURN id(n), n.name, n.iso2 $$) as ("id(n)" agtype, "n.name" agtype, "n.iso2" agtype);
id(n) | n.name | n.iso2
------------------+-----------+--------
1688849860263940 | "Austria" | "AT"
(1 row)
SELECT * FROM cypher('agload_test_graph', $$
MATCH (u:Country {region : "Europe"})
WHERE u.name =~ 'Cro.*'
RETURN u.name, u.region
$$) AS (result_1 agtype, result_2 agtype);
result_1 | result_2
-----------+----------
"Croatia" | "Europe"
(1 row)
SELECT drop_graph('agload_test_graph', true);
NOTICE: drop cascades to 7 other objects
DETAIL: drop cascades to table agload_test_graph._ag_label_vertex
drop cascades to table agload_test_graph._ag_label_edge
drop cascades to table agload_test_graph."Country"
drop cascades to table agload_test_graph."City"
drop cascades to table agload_test_graph.has_city
drop cascades to table agload_test_graph."Country2"
drop cascades to table agload_test_graph."City2"
NOTICE: graph "agload_test_graph" has been dropped
drop_graph
------------
(1 row)
--
-- Test property type conversion
--
SELECT create_graph('agload_conversion');
NOTICE: graph "agload_conversion" has been created
create_graph
--------------
(1 row)
-- vertex: load as agtype
SELECT create_vlabel('agload_conversion','Person1');
NOTICE: VLabel "Person1" has been created
create_vlabel
---------------
(1 row)
SELECT load_labels_from_file('agload_conversion', 'Person1', 'age_load/conversion_vertices.csv', true, true);
load_labels_from_file
-----------------------
(1 row)
SELECT * FROM cypher('agload_conversion', $$ MATCH (n:Person1) RETURN properties(n) $$) as (a agtype);
a
------------------------------------------------------------------------------------
{"id": 1, "bool": true, "__id__": 1, "string": "John Smith", "numeric": 1}
{"id": 2, "bool": false, "__id__": 2, "string": "John", "numeric": -2}
{"id": 3, "bool": true, "__id__": 3, "string": "John Smith", "numeric": 1.4}
{"id": 4, "bool": false, "__id__": 4, "string": "John", "numeric": -10000000000.0}
{"id": 5, "bool": false, "__id__": 5, "string": null, "numeric": 0}
{"id": 6, "bool": false, "__id__": 6, "string": "nUll", "numeric": 3.14}
(6 rows)
-- vertex: load as string
SELECT create_vlabel('agload_conversion','Person2');
NOTICE: VLabel "Person2" has been created
create_vlabel
---------------
(1 row)
SELECT load_labels_from_file('agload_conversion', 'Person2', 'age_load/conversion_vertices.csv', true, false);
load_labels_from_file
-----------------------
(1 row)
SELECT * FROM cypher('agload_conversion', $$ MATCH (n:Person2) RETURN properties(n) $$) as (a agtype);
a
-------------------------------------------------------------------------------------
{"id": "1", "bool": "true", "__id__": 1, "string": "John Smith", "numeric": "1"}
{"id": "2", "bool": "false", "__id__": 2, "string": "John", "numeric": "-2"}
{"id": "3", "bool": "true", "__id__": 3, "string": "John Smith", "numeric": "1.4"}
{"id": "4", "bool": "false", "__id__": 4, "string": "\"John\"", "numeric": "-1e10"}
{"id": "5", "bool": "false", "__id__": 5, "string": "null", "numeric": "0"}
{"id": "6", "bool": "false", "__id__": 6, "string": "nUll", "numeric": "3.14"}
(6 rows)
-- edge: load as agtype
SELECT create_elabel('agload_conversion','Edges1');
NOTICE: ELabel "Edges1" has been created
create_elabel
---------------
(1 row)
SELECT load_edges_from_file('agload_conversion', 'Edges1', 'age_load/conversion_edges.csv', true);
load_edges_from_file
----------------------
(1 row)
SELECT * FROM cypher('agload_conversion', $$ MATCH ()-[e:Edges1]->() RETURN properties(e) $$) as (a agtype);
a
--------------------------------------------------------------
{"bool": true, "string": "John Smith", "numeric": 1}
{"bool": false, "string": "John", "numeric": -2}
{"bool": true, "string": "John Smith", "numeric": 1.4}
{"bool": false, "string": "John", "numeric": -10000000000.0}
{"bool": false, "string": null, "numeric": 0}
{"bool": false, "string": "nUll", "numeric": 3.14}
(6 rows)
-- edge: load as string
SELECT create_elabel('agload_conversion','Edges2');
NOTICE: ELabel "Edges2" has been created
create_elabel
---------------
(1 row)
SELECT load_edges_from_file('agload_conversion', 'Edges2', 'age_load/conversion_edges.csv', false);
load_edges_from_file
----------------------
(1 row)
SELECT * FROM cypher('agload_conversion', $$ MATCH ()-[e:Edges2]->() RETURN properties(e) $$) as (a agtype);
a
-------------------------------------------------------------
{"bool": "true", "string": "John Smith", "numeric": "1"}
{"bool": "false", "string": "John", "numeric": "-2"}
{"bool": "true", "string": "John Smith", "numeric": "1.4"}
{"bool": "false", "string": "\"John\"", "numeric": "-1e10"}
{"bool": "false", "string": "null", "numeric": "0"}
{"bool": "false", "string": "nUll", "numeric": "3.14"}
(6 rows)
SELECT drop_graph('agload_conversion', true);
NOTICE: drop cascades to 6 other objects
DETAIL: drop cascades to table agload_conversion._ag_label_vertex
drop cascades to table agload_conversion._ag_label_edge
drop cascades to table agload_conversion."Person1"
drop cascades to table agload_conversion."Person2"
drop cascades to table agload_conversion."Edges1"
drop cascades to table agload_conversion."Edges2"
NOTICE: graph "agload_conversion" has been dropped
drop_graph
------------
(1 row)