| 697 | } |
| 698 | |
| 699 | func (t *translator) resolveOrdinalOuter(ts tableScope, n ast.Node, prefix string, col int) sem.Expr { |
| 700 | switch ts := ts.(type) { |
| 701 | case *selectScope: |
| 702 | return t.resolveOrdinalOuter(ts.out, n, "out", col) |
| 703 | case *staticTable: |
| 704 | if col < 1 || col > ts.width() { |
| 705 | t.error(n, fmt.Errorf("column %d is out of range", col)) |
| 706 | return badExpr |
| 707 | } |
| 708 | var path []string |
| 709 | if prefix != "" { |
| 710 | path = []string{prefix, ts.typ.Fields[col-1].Name} |
| 711 | } else { |
| 712 | path = []string{ts.typ.Fields[col-1].Name} |
| 713 | } |
| 714 | return sem.NewThis(n, path) |
| 715 | default: |
| 716 | panic(ts) |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | func dedup(scores map[string]int, s string) string { |
| 721 | cnt := scores[s] |