Added vertex attribute cannot be populated in graph

I created a vertex “Company” which had no attributes other than “name”

Later, I added two attributes to this vertex “mongo_id”, “test_id” using this code:

USE GRAPH Companies
CREATE GLOBAL SCHEMA_CHANGE JOB add_test {ALTER VERTEX Company ADD ATTRIBUTE (mongo_id: STRING, test_id STRING);}
RUN SCHEMA_CHANGE JOB add_test

The change seems to have taken effect:

GSQL > ls
---- Graph Companies
Vertex Types:
- VERTEX Company(PRIMARY_ID name STRING, mongo_id STRING, test_id STRING) WITH STATS="OUTDEGREE_BY_EDGETYPE", PRIMARY_ID_AS_ATTRIBUTE="true"
- VERTEX Industry(PRIMARY_ID type STRING) WITH STATS="OUTDEGREE_BY_EDGETYPE", PRIMARY_ID_AS_ATTRIBUTE="true"
Edge Types:
- DIRECTED EDGE PART_OF(FROM Company, TO Industry)
- DIRECTED EDGE CONSIDERS_PEER(FROM Company, TO Company)

Graphs:
- Graph Companies(Company:v, Industry:v, PART_OF:e, CONSIDERS_PEER:e)
Jobs:
Queries:

However, when I try to populate it, I get an error:

GSQL > USE GRAPH Companies
GSQL > BEGIN
GSQL > CREATE LOADING JOB load_social FOR GRAPH Companies {
GSQL > DEFINE FILENAME file1='my_home_dir/data/kg/test.csv";
GSQL > LOAD file1 TO VERTEX Company VALUES ($"name", $"mongo_id", $"test_id") USING header="true", separator=",";
GSQL > }
GSQL > END
Semantic Check Fails: values() index number is 3 while vertex 'Company' has 1 columns!
Failed to create loading jobs: [load_social].

How can I populate this new attribute?

Can you provide a sample of the my_home_dir/data/kg/test.csv source file? The error suggests only 1 column was found in the source file. This could happen because you are specifying a comma as the filed seperator, but maybe the file is using a different separator?

Thanks for your response.

The test.csv was just a dummy file with a single record:

name,mongo_id,test_id
my_company,937298374987,12398419238749

The way that I interpret the error is that the length of the values vector that I am trying to load is 3 (which is correct: name, mongo_id, test_id), while the length of the vertex (company) is 1. That is, the error is saying that I cannot load three values into a vertex with only one defined field. It seems like my attempt to add additional attributes has not made it to this graph.

Hi @bryan,

I believe that your schema change jobs are being reflected on the Global Schema, but not within your schema for the Companies Graph.

Changes to the global schema will not propagate down to the graphs that use elements of the global schema. You will need to drop then re-add that vertex to the local graph for the global changes to show up.

Alternatively, you could just make this a local schema change job, and just update the Vertex type in your Companies graph. This would work exactly like you have written now, just with a local change job vs a global one.

1 Like