uwescience/raco — pull request #239 by dhalperi (2014-06-11 08:03:29+00:00)
Title: [WIP] bug 238 fix

This is a pull request for fixing bug #238.

```myrial
x = [1 as a, 2 as b];
y = [from x as x1, x as x2
emit x2.a, x2.b];
z = [from y emit a];
store(z, OUTPUT);
```

The problem is fairly straightforward.

1. We parse `x2.a` into an [`Unbox` expression](https://github.com/uwescience/raco/blob/master/raco/myrial/parser.py#L548).
2. We turn that `Unbox` [into an `UnnamedAttributeReference`](https://github.com/uwescience/raco/blob/master/raco/myrial/interpreter.py#L204) of `$2`.
3. Since `a` is a duplicate column name in `y` (before the emit claue), we [salt it to `a1`](https://github.com/uwescience/raco/blob/master/raco/myrial/interpreter.py#L204).
4. We fail to resolve `z`'s use of (essentially) `y.a` since the output column names of `y` is `a1,b1`.

In debugging, I found a very relevant [TODO](https://github.com/uwescience/raco/blob/master/raco/myrial/emitarg.py#L39): for an emit clause with no default name specified (I believe this means no `as` clause), we need to pick a default name.

My candidate fix here is simple: when the emit clause is a dotted ref like `x2.a`, use the string after the `.` -- in other words, call it `a`. This ends up adding an `Apply` to rename the field `y.$0` to `a`, so that `z` can reference `y.a`.

@7andrew7 what do you think? This is really the first time I've gone diving for bugs in this part of the myrial code.