MCPcopy Create free account
hub / github.com/brimdata/super / sqlQueryBody

Method sqlQueryBody

compiler/sfmt/ast.go:699–791  ·  view source on GitHub ↗
(query ast.SQLQueryBody)

Source from the content-addressed store, hash-verified

697}
698
699func (c *canon) sqlQueryBody(query ast.SQLQueryBody) {
700 switch query := query.(type) {
701 case *ast.SQLQuery:
702 if with := query.With; with != nil {
703 c.next()
704 c.write("with ")
705 if with.Recursive {
706 c.write("recursive ")
707 }
708 for i, cte := range with.CTEs {
709 if i > 0 {
710 c.write(", ")
711 }
712 c.write("%s as ", cte.Name.Name)
713 if cte.Materialized {
714 c.write("materialized ")
715 }
716 c.open("(")
717 c.sqlQueryBody(cte.Body)
718 c.close()
719 c.ret()
720 c.write(")")
721 }
722 }
723 c.head = true
724 c.sqlQueryBody(query.Body)
725 if query.OrderBy != nil {
726 c.ret()
727 c.write("order by")
728 c.sortExprs(query.OrderBy.Exprs)
729 }
730 if limoff := query.Limit; limoff != nil {
731 c.ret()
732 c.write("limit ")
733 c.expr(limoff.Limit, "")
734 if limoff.Offset != nil {
735 c.ret()
736 c.write("offset ")
737 c.expr(limoff.Offset, "")
738 }
739 }
740 case *ast.SQLSelect:
741 c.next()
742 c.write("select ")
743 if query.Distinct {
744 c.write("distinct ")
745 }
746 for i, a := range query.Selection.Args {
747 if i > 0 {
748 c.write(", ")
749 }
750 c.expr(&a, "")
751 }
752 if query.From != nil {
753 c.head = true
754 c.ret()
755 c.write("from ")
756 c.tableExpr(query.From)

Callers 1

opMethod · 0.95

Calls 9

nextMethod · 0.95
sortExprsMethod · 0.95
exprMethod · 0.95
tableExprMethod · 0.95
exprsMethod · 0.95
retMethod · 0.80
writeMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected