| 776 | } |
| 777 | |
| 778 | func (node *WindowDef) doc(p *PrettyCfg) pretty.Doc { |
| 779 | rows := make([]pretty.TableRow, 0, 4) |
| 780 | if node.RefName != "" { |
| 781 | rows = append(rows, p.row("", p.Doc(&node.RefName))) |
| 782 | } |
| 783 | if len(node.Partitions) > 0 { |
| 784 | rows = append(rows, p.row("PARTITION BY", p.Doc(&node.Partitions))) |
| 785 | } |
| 786 | if len(node.OrderBy) > 0 { |
| 787 | rows = append(rows, node.OrderBy.docRow(p)) |
| 788 | } |
| 789 | if node.Frame != nil { |
| 790 | rows = append(rows, node.Frame.docRow(p)) |
| 791 | } |
| 792 | if len(rows) == 0 { |
| 793 | return pretty.Text("()") |
| 794 | } |
| 795 | return p.bracket("(", p.rlTable(rows...), ")") |
| 796 | } |
| 797 | |
| 798 | func (wf *WindowFrame) docRow(p *PrettyCfg) pretty.TableRow { |
| 799 | kw := "RANGE" |