Seems like I might be missing something obvious, but I don’t see any substring, left, right, mid, or any operation to get a substring. In my specific case, I want the first 3 characters of a string attribute that can be of varying lengths.
string b = "aa ABC aaa";
string c = " a A ";
PRINT trim(BOTH trim(BOTH " " FROM c) FROM b);
# prints "BC"
@markmegerian can you give me an example. I’ve never written this before, but instinctually I’m thinking of using the LIKE operator to do string matching or something like (above) or a combo of both.
Sure, here is an example. I don’t think I can combine LIKE and TRIM to get this to work.
Vertex Part - STRING partNum, STRING partDesc
The first 3 characters of any partNum is the category of part.
For instance, partNum J4566, “Front right body panel”
partNum J45 “Body panel”
I need to be able to go from J4566 to the first 3 characters to get to the category.
Note, I have changed the specifics, but this is the general idea. I don’t own the schema so I cannot change the data, I need to work with this. There is no EDGE between them, I just need to get to it using a simple substring(partNum,3) or something to that effect. While I realize that it would be ideal to have an EDGE, I still am interested in a general solution for substring.
True, but the issue I have encountered dozens of times, if not more, is that I want to use the sortable string representation inside my query, in an accumulator, and also use it to return human-readable output.
So using the epoch achieves the sorting part, but not the output part. Say I want a Person Vertex to have a MapAccum<STRING, INT> where the STRING is human readable date and the INT is a count of something. I have to construct the date (like in my Fun with Date Strings post) but having a UDF to accomplish this would be much cleaner.
One other point, even though there is conversion using datetime_format at print time, this doesn’t solve the problem either. I need the date string at query time, inside ACCUM, not just at PRINT time.