TUPLE Syntax Error

TYPEDEF TUPLE <INT id, INT score> MatchResultPair;

see the compiling error when run in up line command from gsql function. what is wrong?
line 85:4 mismatched input ‘typedef’ expecting {ABORT, ANY, AVG, BREAK, BY, CASE, COALESCE, COMMIT, CONTINUE, COUNT, DATETIME_ADD, DATETIME_SUB, DELETE, DISTINCT, FALSE, FILE, FOREACH, GROUP, IF, INSERT, ISEMPTY, LASTHOP, LIST, LOG, MAP, MATCH, MAX, MIN, NOT, NOW, PATH, PER, PRINT, RAISE, RANGE, RETURN, SELECT, SELECT_VERTEX, SRC, SUM, TGT, TO_DATETIME, TRIM, TRUE, TRY, UPDATE, WHILE, GSQL_INT_MAX, GSQL_INT_MIN, GSQL_UINT_MAX, RESET_COLLECTION_ACCUM, ‘__ENGINE__E_ATTR’, ‘__ENGINE__SRC_ATTR’, ‘__ENGINE__TGT_ATTR’, ‘__ENGINE__V_ATTR’, ‘__ENGINE__SRC_VAL’, ‘__ENGINE__TGT_VAL’, ‘__ENGINE__V_VAL’, ‘__ENGINE__MESSAGE’, ‘__ENGINE__CONTEXT’, ‘__ENGINE__REQUEST’, ‘__ENGINE__SERVICEAPI’, ‘(’, ‘[’, ‘-’, ‘.’, ‘_’, CONST_INT, CONST_STR, NAME, GACCNAME}
Parsing encountered 1 syntax error(s)

reverse the data type and the variable name:

TYPEDEF TUPLE <id INT , score INT > MatchResultPair;

I have reversed the order and retry:
TYPEDEF TUPLE <id INT, score INT> MatchResultPair;

still got the same error:
line 85:4 mismatched input ‘typedef’ expecting {ABORT, ANY, AVG, BREAK, BY, CASE, COALESCE, COMMIT, CONTINUE, COUNT, DATETIME_ADD, DATETIME_SUB, DELETE, DISTINCT, FALSE, FILE, FOREACH, GROUP, IF, INSERT, ISEMPTY, LASTHOP, LIST, LOG, MAP, MATCH, MAX, MIN, NOT, NOW, PATH, PER, PRINT, RAISE, RANGE, RETURN, SELECT, SELECT_VERTEX, SRC, SUM, TGT, TO_DATETIME, TRIM, TRUE, TRY, UPDATE, WHILE, GSQL_INT_MAX, GSQL_INT_MIN, GSQL_UINT_MAX, RESET_COLLECTION_ACCUM, ‘__ENGINE__E_ATTR’, ‘__ENGINE__SRC_ATTR’, ‘__ENGINE__TGT_ATTR’, ‘__ENGINE__V_ATTR’, ‘__ENGINE__SRC_VAL’, ‘__ENGINE__TGT_VAL’, ‘__ENGINE__V_VAL’, ‘__ENGINE__MESSAGE’, ‘__ENGINE__CONTEXT’, ‘__ENGINE__REQUEST’, ‘__ENGINE__SERVICEAPI’, ‘(’, ‘[’, ‘-’, ‘.’, ‘_’, CONST_INT, CONST_STR, NAME, GACCNAME}

I am quite confident that the syntax is correct. I believe the issue is where in the query you have coded the typedef. It must appear at the very top, before any other declarations. Most importantly it must precede the declaration of any accumulators. If you still have trouble, post the entire query, not just that line.

1 Like