Simple string concatenation

Is there any way to concatenate a string? The documentation mentions the + concat operator, but it doesn’t seem to be allowed:

BEGIN

CREATE QUERY searchSystem(VERTEX<system_> sys, STRING term) FOR GRAPH ty { 

  f={sys};

songRes = SELECT s FROM 

    f-(SA:sa)-A:a-(AB:ab)-C:c 

    WHERE c.serch_col LIKE "%"+term+"%" LIMIT 10;

PRINT songRes;

}

END

The syntax error is saying it needs to be a literal or a variable. When I make it a variable, I still can’t assign it using string manipulation:

BEGIN

CREATE QUERY s() FOR GRAPH ty { 

  STRING v1 = "asdf";

  STRING v2 = "zxcv";

  STRING v3 = v1+v2;

  PRINT v3;

}

END

Is there any work around for this?

I’d add to what XinYu says, that if you want inline functions to extend the effective syntax then we go to UDF’s.

For example I wrote a regular expression pattern match to use in the same way you are using LIKE below.

I was going to blog about this specific thing, would that be of interest? If so I’ll move it back up my list of work.

Regards

Richard Henderson

Solution Engineer

1 Like

I’d like to see this.

I have to say, I have struggles with GSQ due to me expecting GSQL should work somewhat like SQL, but I keep on getting stymied.

@clemwang Follow up thread on this: GSQL matching using regular expression

Also it might be worth checking out a few sample string-based UDF samples https://github.com/tigergraph/ecosys/tree/master/UDF#string-based-udf