GSQL Graph Name Parameters and Include Files

Does TigerGraph allow the ability to use any sort of parameter when specifying a graph name to use, say, in a schema change job or a loading job?

For example, when creating a schema change job, we might specify something like

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH dev {
    ...
}

This is great if you only have one graph named dev. What if we have several variants of the same graph–say for development (dev), quality assurance (qa), and prodution. Perhaps we even have a couple of developers or data scientists running side experiments who have their own editions (dev_miriam) and (ds_priyanka).

To script schema changes to all of those graphs, it looks like I now actually need five different copies of what are essentially the same script.

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH dev {
    ...
}

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH qa{
    ...
}

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH prod {
    ...
}

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH dev_miriam {
    ...
}

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH ds_priayanka {
    ...
}

That is a lot to maintain.

What if I make a change to the script? Now, I have to update five different scripts and hope I don’t miss one.

Wouldn’t it be more convenient to be able to specify the graph name as a parameter like so?

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH $graph_name {
    ...
}

Another feature that would be really helpful is the ability to include files in other GSQL scripts. Perhaps I have some kind of boilerplate code I want to add to many schema change or load jobs. It would be great to do something like the following.

CREATE SCHEMA_CHANGE JOB schema_update_job FOR GRAPH qa{
    #include "/home/tigergraph/tigergraph/load-data/my_common_code.gsql"
}

Perhaps these features are already available and I am just missing them. If so, please correct my misunderstanding. If they are not available, then please consider as possible features for a future release.

Yes, this would be very helpful to have a Session Parameter, something like sys.graph_name. This would also come in handy in writing queries too :wink:

@anthony.gatlin @demit733 Really great points. I’ll bring that back to the product team. I totally understand where you are coming from. When working in Optum we ran into this as well. We eventually developed an open source plugin to accommodate “enterprise developing” (multiple users coding, multiple environments, multiple graphs, lots of modifications daily)

Dug out an old post where I complied information around the tool: CICD Process for Developers

Code Snippets:

drop query cosine_patient_demographics

# Computes the cosine similarity between a given vertex & every other vertex
create query cosine_patient_demographics(STRING firstName, STRING lastName, INT topK) FOR GRAPH @graphname@ returns (MapAccum<VERTEX, DOUBLE>) {
    MapAccum<VERTEX, DOUBLE> @@topk_result;
    SumAccum<DOUBLE> @latitude, @longitude, @distance, @similarity, @ageCount;
    SumAccum<INT> @age, @sexCount, @raceCount, @ethnicityCount;
    SumAccum<STRING> @sex, @race, @ethnicity;
    MaxAccum<DOUBLE> @@maxDistance = 0;
create loading job loadAllergies for graph @graphname@ {

    define filename f1;

    load f1
        to VERtex _Allergies values ($0, $5, $6, $1, $2),

Sample Project using Giraffle:

Let me know if you have any follow up questions!