@@ -233,3 +233,127 @@ NOTICE: graph "agload_test_graph" has been dropped
233
233
234
234
(1 row)
235
235
236
+ --
237
+ -- Test property type conversion
238
+ --
239
+ SELECT create_graph('agload_conversion');
240
+ NOTICE: graph "agload_conversion" has been created
241
+ create_graph
242
+ --------------
243
+
244
+ (1 row)
245
+
246
+ -- vertex: load as agtype
247
+ SELECT create_vlabel('agload_conversion','Person1');
248
+ NOTICE: VLabel "Person1" has been created
249
+ create_vlabel
250
+ ---------------
251
+
252
+ (1 row)
253
+
254
+ SELECT load_labels_from_file('agload_conversion', 'Person1', 'age_load/conversion_vertices.csv', true, true);
255
+ load_labels_from_file
256
+ -----------------------
257
+
258
+ (1 row)
259
+
260
+ SELECT * FROM cypher('agload_conversion', $$ MATCH (n:Person1) RETURN properties(n) $$) as (a agtype);
261
+ a
262
+ ------------------------------------------------------------------------------------
263
+ {"id": 1, "bool": true, "__id__": 1, "string": "John Smith", "numeric": 1}
264
+ {"id": 2, "bool": false, "__id__": 2, "string": "John", "numeric": -2}
265
+ {"id": 3, "bool": true, "__id__": 3, "string": "John Smith", "numeric": 1.4}
266
+ {"id": 4, "bool": false, "__id__": 4, "string": "John", "numeric": -10000000000.0}
267
+ {"id": 5, "bool": false, "__id__": 5, "string": null, "numeric": 0}
268
+ {"id": 6, "bool": false, "__id__": 6, "string": "nUll", "numeric": 3.14}
269
+ (6 rows)
270
+
271
+ -- vertex: load as string
272
+ SELECT create_vlabel('agload_conversion','Person2');
273
+ NOTICE: VLabel "Person2" has been created
274
+ create_vlabel
275
+ ---------------
276
+
277
+ (1 row)
278
+
279
+ SELECT load_labels_from_file('agload_conversion', 'Person2', 'age_load/conversion_vertices.csv', true, false);
280
+ load_labels_from_file
281
+ -----------------------
282
+
283
+ (1 row)
284
+
285
+ SELECT * FROM cypher('agload_conversion', $$ MATCH (n:Person2) RETURN properties(n) $$) as (a agtype);
286
+ a
287
+ -------------------------------------------------------------------------------------
288
+ {"id": "1", "bool": "true", "__id__": 1, "string": "John Smith", "numeric": "1"}
289
+ {"id": "2", "bool": "false", "__id__": 2, "string": "John", "numeric": "-2"}
290
+ {"id": "3", "bool": "true", "__id__": 3, "string": "John Smith", "numeric": "1.4"}
291
+ {"id": "4", "bool": "false", "__id__": 4, "string": "\"John\"", "numeric": "-1e10"}
292
+ {"id": "5", "bool": "false", "__id__": 5, "string": "null", "numeric": "0"}
293
+ {"id": "6", "bool": "false", "__id__": 6, "string": "nUll", "numeric": "3.14"}
294
+ (6 rows)
295
+
296
+ -- edge: load as agtype
297
+ SELECT create_elabel('agload_conversion','Edges1');
298
+ NOTICE: ELabel "Edges1" has been created
299
+ create_elabel
300
+ ---------------
301
+
302
+ (1 row)
303
+
304
+ SELECT load_edges_from_file('agload_conversion', 'Edges1', 'age_load/conversion_edges.csv', true);
305
+ load_edges_from_file
306
+ ----------------------
307
+
308
+ (1 row)
309
+
310
+ SELECT * FROM cypher('agload_conversion', $$ MATCH ()-[e:Edges1]->() RETURN properties(e) $$) as (a agtype);
311
+ a
312
+ --------------------------------------------------------------
313
+ {"bool": true, "string": "John Smith", "numeric": 1}
314
+ {"bool": false, "string": "John", "numeric": -2}
315
+ {"bool": true, "string": "John Smith", "numeric": 1.4}
316
+ {"bool": false, "string": "John", "numeric": -10000000000.0}
317
+ {"bool": false, "string": null, "numeric": 0}
318
+ {"bool": false, "string": "nUll", "numeric": 3.14}
319
+ (6 rows)
320
+
321
+ -- edge: load as string
322
+ SELECT create_elabel('agload_conversion','Edges2');
323
+ NOTICE: ELabel "Edges2" has been created
324
+ create_elabel
325
+ ---------------
326
+
327
+ (1 row)
328
+
329
+ SELECT load_edges_from_file('agload_conversion', 'Edges2', 'age_load/conversion_edges.csv', false);
330
+ load_edges_from_file
331
+ ----------------------
332
+
333
+ (1 row)
334
+
335
+ SELECT * FROM cypher('agload_conversion', $$ MATCH ()-[e:Edges2]->() RETURN properties(e) $$) as (a agtype);
336
+ a
337
+ -------------------------------------------------------------
338
+ {"bool": "true", "string": "John Smith", "numeric": "1"}
339
+ {"bool": "false", "string": "John", "numeric": "-2"}
340
+ {"bool": "true", "string": "John Smith", "numeric": "1.4"}
341
+ {"bool": "false", "string": "\"John\"", "numeric": "-1e10"}
342
+ {"bool": "false", "string": "null", "numeric": "0"}
343
+ {"bool": "false", "string": "nUll", "numeric": "3.14"}
344
+ (6 rows)
345
+
346
+ SELECT drop_graph('agload_conversion', true);
347
+ NOTICE: drop cascades to 6 other objects
348
+ DETAIL: drop cascades to table agload_conversion._ag_label_vertex
349
+ drop cascades to table agload_conversion._ag_label_edge
350
+ drop cascades to table agload_conversion."Person1"
351
+ drop cascades to table agload_conversion."Person2"
352
+ drop cascades to table agload_conversion."Edges1"
353
+ drop cascades to table agload_conversion."Edges2"
354
+ NOTICE: graph "agload_conversion" has been dropped
355
+ drop_graph
356
+ ------------
357
+
358
+ (1 row)
359
+
0 commit comments