(pos Pos)
| 648 | } |
| 649 | |
| 650 | func (p *Parser) parseTableColumnExpr(pos Pos) (*ColumnDef, error) { |
| 651 | // Not a column definition, just return |
| 652 | column := &ColumnDef{NamePos: pos} |
| 653 | // parse column name |
| 654 | name, err := p.ParseNestedIdentifier(p.Pos()) |
| 655 | if err != nil { |
| 656 | return nil, err |
| 657 | } |
| 658 | column.Name = name |
| 659 | columnEnd := name.End() |
| 660 | |
| 661 | if p.matchTokenKind(TokenKindIdent) && !p.matchKeyword(KeywordRemove) { |
| 662 | columnType, err := p.parseColumnType(p.Pos()) |
| 663 | if err != nil { |
| 664 | return nil, err |
| 665 | } |
| 666 | column.Type = columnType |
| 667 | columnEnd = columnType.End() |
| 668 | } |
| 669 | |
| 670 | nullable := p.tryParseNull(p.Pos()) |
| 671 | if nullable != nil { |
| 672 | columnEnd = nullable.End() |
| 673 | } |
| 674 | notNull, err := p.tryParseNotNull(p.Pos()) |
| 675 | if err != nil { |
| 676 | return nil, err |
| 677 | } |
| 678 | if notNull != nil { |
| 679 | columnEnd = notNull.End() |
| 680 | } |
| 681 | |
| 682 | switch { |
| 683 | case p.tryConsumeKeywords(KeywordDefault): |
| 684 | column.DefaultExpr, err = p.parseExpr(p.Pos()) |
| 685 | columnEnd = column.DefaultExpr.End() |
| 686 | case p.tryConsumeKeywords(KeywordMaterialized): |
| 687 | column.MaterializedExpr, err = p.parseExpr(p.Pos()) |
| 688 | columnEnd = column.MaterializedExpr.End() |
| 689 | case p.tryConsumeKeywords(KeywordAlias): |
| 690 | column.AliasExpr, err = p.parseExpr(p.Pos()) |
| 691 | columnEnd = column.AliasExpr.End() |
| 692 | } |
| 693 | if err != nil { |
| 694 | return nil, err |
| 695 | } |
| 696 | |
| 697 | comment, err := p.tryParseColumnComment(p.Pos()) |
| 698 | if err != nil { |
| 699 | return nil, err |
| 700 | } |
| 701 | if comment != nil { |
| 702 | columnEnd = comment.End() |
| 703 | } |
| 704 | |
| 705 | codec, err := p.tryParseCompressionCodecs(p.Pos()) |
| 706 | if err != nil { |
| 707 | return nil, err |
no test coverage detected