Arrays : no viable alternative error

31 views
Skip to first unread message

Meghana Ponnuru

unread,
Mar 10, 2020, 12:10:31 PM3/10/20
to gsql-...@opengsql.org
Hello , 
I'm trying to insert values in Array and attach it to vertex set. But I get no viable alternative at input error.

Example:

ArrayAccum<SumAccum<double>> @@squares[5][10];
ArrayAccum<SumAccum<double>> @@norm[5];
SumAccum<double> @@value;

Start={Person.*}

CV = SELECT p FROM Start:p

FOREACH i IN RANGE [0,5] DO
    @@value=0;

         FOREACH j in RANGE [0,9] DO  
              @@value=(i*i) + (j*j);
              p.@@squares[i][j]=(i*j);
         END;

     p.@norm[i]=sqrt(@@value);
END;

I tried using ACCUM and POST-ACCUM but I got an error NO VIABLE ALTERNATIVE AT INPUT error.

kevin.cai

unread,
Mar 17, 2020, 5:05:02 PM3/17/20
to gsql-users
Hi Meghana,

There are a few things you can change in the query.

Start={Person.*} missing semicolon at the end
CV = select p from start:p missing semicolon at the end

p.@@squares[i][j]=(i*j) the line that returns the error you mentioned.
This is because @@squares, which you defined in the first line, is a global accumulator. Global accumulators are not attached to vertices.
To access it, just use this:
@@squares[i][j]=(i*j)

p.@norm[i]=sqrt(@@value); local accumulator can't be updated unless within a select statement.

Thanks,
Kevin
Reply all
Reply to author
Forward
0 new messages