uwescience / myria-web

Web frontend for Myria
https://demo.myria.cs.washington.edu
Other
11 stars 14 forks source link

Stateful Apply Not allowing AS #235

Closed ljorr1 closed 9 years ago

ljorr1 commented 9 years ago

We are using the stateful apply operator and want to do this...

apply RunningRank(haloGrp)
{
    [0 as _rank, -1 as _grp];
    [case when haloGrp = _grp then _rank + 1 else 1 end as _rank, haloGrp as _grp];
    _rank;
};

rankedEdges = [from scan(public:vulcan:edgesConnectedSplitSort) as e emit e.nowGroup, e.currentTime, RunningRank(e.currentGroup) as splitOrder, e.currentGroup, e.nextGroup, e.sharedParticleCount];
edges = [from rankedEdges where splitOrder = 1 emit *];
store(edges, public:vulcan:edgesTree);

We get the error that AS is not allowed. When removing the "as _grp", we get another unknown error from postgres. To fix this, we had to change the "haloGrp as _grp" to

case when haloGrp = _grp then _grp else haloGrp end

We think we somehow needed the _grp keyword in the query but don't know why.

dhalperi commented 9 years ago

@7andrew7 will have to check me here, but I believe that as statements are disallowed in the updaters, because the state variables (in this case, _rank and _grp) already have names that were assigned in the initializers the line above.

dhalperi commented 9 years ago

@ljorr1 Did that answer end up making sense? This is not a bug – AS is only allowed in the first line of the StatefulApply, otherwise, the output name of the update statement is defined positionally.