Skip to content

fix: add delimiter parameter to load_labels_from_file and load_edges_from_file#2469

Open
mmustafasenoglu wants to merge 2 commits into
apache:masterfrom
mmustafasenoglu:fix/delimiter-parameter
Open

fix: add delimiter parameter to load_labels_from_file and load_edges_from_file#2469
mmustafasenoglu wants to merge 2 commits into
apache:masterfrom
mmustafasenoglu:fix/delimiter-parameter

Conversation

@mmustafasenoglu

Copy link
Copy Markdown
Contributor

Summary

Closes #2449

Both load_labels_from_file and load_edges_from_file relied on PostgreSQL COPY's default comma delimiter, causing silent data corruption on labels and segfault on edges when using non-comma-delimited files.

This adds an optional delimiter TEXT parameter (default comma) to both functions, allowing users to specify the field separator.

Changes

  • create_copy_options() in both ag_load_labels.c and ag_load_edges.c now accepts and passes the delimiter to COPY
  • SQL function signatures updated with new delimiter parameter (default comma)
  • Regression tests added for pipe-delimited vertex and edge files

Usage

-- Pipe-delimited vertex file
SELECT load_labels_from_file('graph', 'Label', 'file.csv', true, false, '|');

-- Pipe-delimited edge file
SELECT load_edges_from_file('graph', 'Edge', 'file.csv', false, '|');

Backward Compatibility

The new parameter has a default value of comma, so all existing calls continue to work without changes.

…from_file

Closes apache#2449

Both load_labels_from_file and load_edges_from_file relied on PostgreSQL
COPY's default comma delimiter, causing silent data corruption on labels
and segfault on edges when using non-comma-delimited files.

This adds an optional 'delimiter' TEXT parameter (default ',') to both
functions, allowing users to specify the field separator:

  SELECT load_labels_from_file('graph', 'Label', 'file.csv', true, false, '|');
  SELECT load_edges_from_file('graph', 'Edge', 'file.csv', false, '|');

Changes:
- create_copy_options() now accepts and passes the delimiter to COPY
- SQL function signatures updated with new delimiter parameter
- Regression tests added for pipe-delimited vertex and edge files
@gregfelice

Copy link
Copy Markdown
Contributor

Heads up @mmustafasenoglu — CI had never actually run on this branch (the workflow runs were sitting unapproved, which is why the PR showed no checks). I've approved them, and Build / Regression now fails.

The cause is a missing expected-output regeneration. The new pipe-delimited cases were added to regress/sql/age_load.sql, but regress/expected/age_load.out was not updated to match, so pg_regress diffs the new output against an expected file that does not contain it:

diff -U3 regress/expected/age_load.out regress/results/age_load.out
@@ -512,6 +512,65 @@
+--
+-- Test delimiter parameter for pipe-delimited files
+--
+SELECT create_graph('agload_pipe');
+NOTICE:  graph "agload_pipe" has been created
...

Regenerating regress/expected/age_load.out from a clean run should clear it. Worth re-checking the whole file rather than pasting just the new block, so the surrounding row counts and NOTICE ordering stay consistent.

Ping me once CI is green and I'll review the change itself — I have not looked at the delimiter handling yet, only at why the build was red.

…limiter tests

- Fix bare Cypher queries to use proper cypher() wrapper
- Add missing pipe delimiter test section to age_load.out expected output

The CI Build/Regression was failing because:
1. regress/sql/age_load.sql had bare Cypher queries without cypher() wrapper
2. regress/expected/age_load.out was not updated with pipe delimiter test output
@MuhammadTahaNaveed

MuhammadTahaNaveed commented Jul 15, 2026

Copy link
Copy Markdown
Member

@mmustafasenoglu There are a few minor diffs in age_load.out. Additionally, the updated function definitions haven't been added to age--1.8.0--y.y.y.sql, which is why age_upgrade.out is failing. LGTM otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants