(n *pcast.AggregateFuncExpr)
| 737 | } |
| 738 | |
| 739 | func (c *cc) convertAggregateFuncExpr(n *pcast.AggregateFuncExpr) *ast.FuncCall { |
| 740 | name := strings.ToLower(n.F) |
| 741 | fn := &ast.FuncCall{ |
| 742 | Func: &ast.FuncName{ |
| 743 | Name: name, |
| 744 | }, |
| 745 | Funcname: &ast.List{ |
| 746 | Items: []ast.Node{ |
| 747 | NewIdentifier(name), |
| 748 | }, |
| 749 | }, |
| 750 | Args: &ast.List{}, |
| 751 | AggOrder: &ast.List{}, |
| 752 | } |
| 753 | |
| 754 | // GROUP_CONCAT has special handling: |
| 755 | // TiDB always adds the separator as the last argument |
| 756 | // We need to extract it and use SEPARATOR syntax |
| 757 | args := n.Args |
| 758 | var separator string |
| 759 | if name == "group_concat" && len(args) >= 2 { |
| 760 | // The last arg is always the separator |
| 761 | if value, ok := args[len(args)-1].(*driver.ValueExpr); ok { |
| 762 | separator = value.GetString() |
| 763 | args = args[:len(args)-1] |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | for _, a := range args { |
| 768 | if value, ok := a.(*driver.ValueExpr); ok { |
| 769 | if value.GetInt64() == int64(1) { |
| 770 | fn.AggStar = true |
| 771 | continue |
| 772 | } |
| 773 | } |
| 774 | fn.Args.Items = append(fn.Args.Items, c.convert(a)) |
| 775 | } |
| 776 | if n.Distinct { |
| 777 | fn.AggDistinct = true |
| 778 | } |
| 779 | |
| 780 | // Store separator for GROUP_CONCAT (only if non-default) |
| 781 | if name == "group_concat" && separator != "" && separator != "," { |
| 782 | fn.Separator = &separator |
| 783 | } |
| 784 | |
| 785 | return fn |
| 786 | } |
| 787 | |
| 788 | func (c *cc) convertAlterDatabaseStmt(n *pcast.AlterDatabaseStmt) ast.Node { |
| 789 | return todo(n) |
no test coverage detected