| 724 | } |
| 725 | |
| 726 | func (node *WindowDef) doc(p *PrettyCfg) pretty.Doc { |
| 727 | rows := make([]pretty.TableRow, 0, 4) |
| 728 | if node.RefName != "" { |
| 729 | rows = append(rows, p.row("", p.Doc(&node.RefName))) |
| 730 | } |
| 731 | if len(node.Partitions) > 0 { |
| 732 | rows = append(rows, p.row("PARTITION BY", p.Doc(&node.Partitions))) |
| 733 | } |
| 734 | if len(node.OrderBy) > 0 { |
| 735 | rows = append(rows, node.OrderBy.docRow(p)) |
| 736 | } |
| 737 | if node.Frame != nil { |
| 738 | rows = append(rows, node.Frame.docRow(p)) |
| 739 | } |
| 740 | if len(rows) == 0 { |
| 741 | return pretty.Text("()") |
| 742 | } |
| 743 | return p.bracket("(", p.rlTable(rows...), ")") |
| 744 | } |
| 745 | |
| 746 | func (wf *WindowFrame) docRow(p *PrettyCfg) pretty.TableRow { |
| 747 | kw := "RANGE" |