Format formats the node
(buf *nodeBuffer)
| 696 | |
| 697 | // Format formats the node |
| 698 | func (p *TablePartition) Format(buf *nodeBuffer) { |
| 699 | buf.Printf("partition by %s", strings.ToLower(p.Type)) |
| 700 | if p.Columns != nil { |
| 701 | // RANGE COLUMNS, LIST COLUMNS, KEY |
| 702 | var cols []string |
| 703 | for _, c := range p.Columns { |
| 704 | cols = append(cols, String(&c)) |
| 705 | } |
| 706 | buf.Printf(" (%s)", strings.Join(cols, ", ")) |
| 707 | } else if p.Expr != nil { |
| 708 | // RANGE, LIST, HASH |
| 709 | buf.Printf(" (%v)", p.Expr) |
| 710 | } |
| 711 | if p.Partitions > 0 { |
| 712 | buf.Printf(" partitions %d", p.Partitions) |
| 713 | } |
| 714 | if len(p.Definitions) > 0 { |
| 715 | buf.Printf("\n(") |
| 716 | for i, def := range p.Definitions { |
| 717 | if i > 0 { |
| 718 | buf.Printf(",\n ") |
| 719 | } |
| 720 | def.Format(buf) |
| 721 | } |
| 722 | buf.Printf(")") |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | // TableSpec describes the structure of a table from a CREATE TABLE statement |
| 727 | type TableSpec struct { |