(n *pcast.CommonTableExpression)
| 602 | } |
| 603 | |
| 604 | func (c *cc) convertCommonTableExpression(n *pcast.CommonTableExpression) *ast.CommonTableExpr { |
| 605 | if n == nil { |
| 606 | return nil |
| 607 | } |
| 608 | |
| 609 | name := n.Name.String() |
| 610 | |
| 611 | columns := &ast.List{} |
| 612 | for _, col := range n.ColNameList { |
| 613 | columns.Items = append(columns.Items, NewIdentifier(col.String())) |
| 614 | } |
| 615 | |
| 616 | // CTE Query is wrapped in SubqueryExpr by TiDB parser. |
| 617 | // We need to unwrap it to get the SelectStmt directly, |
| 618 | // otherwise it would be double-wrapped with parentheses. |
| 619 | var cteQuery ast.Node |
| 620 | if n.Query != nil { |
| 621 | cteQuery = c.convert(n.Query.Query) |
| 622 | } |
| 623 | |
| 624 | return &ast.CommonTableExpr{ |
| 625 | Ctename: &name, |
| 626 | Ctequery: cteQuery, |
| 627 | Ctecolnames: columns, |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | func (c *cc) convertWithClause(n *pcast.WithClause) *ast.WithClause { |
| 632 | if n == nil { |
no test coverage detected