Skip to content

Commit

Permalink
Merge #29406 #29407
Browse files Browse the repository at this point in the history
29406: pretty: teach IF and NULLIF to pretty print r=mjibson a=mjibson

Release note: None

29407: pretty: remove double space before AS of CREATE TABLE AS r=mjibson a=mjibson

Release note: None

Co-authored-by: Matt Jibson <[email protected]>
  • Loading branch information
craig[bot] and maddyblue committed Aug 31, 2018
3 parents 9f1a5b5 + c171db2 + a4c0695 commit b33f4fb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/sql/sem/tree/pretty.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ func (node *CreateTable) doc(p *PrettyCfg) pretty.Doc {
d = p.nestUnder(
pretty.Concat(
d,
pretty.Text(" AS"),
pretty.Text("AS"),
),
p.Doc(node.AsSource),
)
Expand Down Expand Up @@ -1121,3 +1121,18 @@ func (node *IfErrExpr) doc(p *PrettyCfg) pretty.Doc {
}
return pretty.Bracket(s, pretty.Join(",", d...), ")")
}

func (node *IfExpr) doc(p *PrettyCfg) pretty.Doc {
return pretty.Bracket("IF(", pretty.Join(",",
p.Doc(node.Cond),
p.Doc(node.True),
p.Doc(node.Else),
), ")")
}

func (node *NullIfExpr) doc(p *PrettyCfg) pretty.Doc {
return pretty.Bracket("NULLIF(", pretty.Join(",",
p.Doc(node.Expr1),
p.Doc(node.Expr2),
), ")")
}

0 comments on commit b33f4fb

Please sign in to comment.