Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 1347 | |
| 1348 | // Format implements the NodeFormatter interface. |
| 1349 | func (node *FuncExpr) Format(ctx *FmtCtx) { |
| 1350 | var typ string |
| 1351 | if node.Type != 0 { |
| 1352 | typ = funcTypeName[node.Type] + " " |
| 1353 | } |
| 1354 | |
| 1355 | // We need to remove name anonymization for the function name in |
| 1356 | // particular. Do this by overriding the flags. |
| 1357 | ctx.WithFlags(ctx.flags&^FmtAnonymize, func() { |
| 1358 | ctx.FormatNode(&node.Func) |
| 1359 | }) |
| 1360 | |
| 1361 | ctx.WriteByte('(') |
| 1362 | ctx.WriteString(typ) |
| 1363 | ctx.FormatNode(&node.Exprs) |
| 1364 | if len(node.OrderBy) > 0 { |
| 1365 | ctx.WriteByte(' ') |
| 1366 | ctx.FormatNode(&node.OrderBy) |
| 1367 | } |
| 1368 | ctx.WriteByte(')') |
| 1369 | if ctx.HasFlags(FmtParsable) && node.typ != nil { |
| 1370 | if node.fnProps.AmbiguousReturnType { |
| 1371 | // There's no type annotation available for tuples. |
| 1372 | // TODO(jordan,knz): clean this up. AmbiguousReturnType should be set only |
| 1373 | // when we should and can put an annotation here. #28579 |
| 1374 | if node.typ.Family() != types.TupleFamily { |
| 1375 | ctx.WriteString(":::") |
| 1376 | ctx.Buffer.WriteString(node.typ.SQLString()) |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | if node.Filter != nil { |
| 1381 | ctx.WriteString(" FILTER (WHERE ") |
| 1382 | ctx.FormatNode(node.Filter) |
| 1383 | ctx.WriteString(")") |
| 1384 | } |
| 1385 | if window := node.WindowDef; window != nil { |
| 1386 | ctx.WriteString(" OVER ") |
| 1387 | if window.Name != "" { |
| 1388 | ctx.FormatNode(&window.Name) |
| 1389 | } else { |
| 1390 | ctx.FormatNode(window) |
| 1391 | } |
| 1392 | } |
| 1393 | } |
| 1394 | |
| 1395 | // CaseExpr represents a CASE expression. |
| 1396 | type CaseExpr struct { |
nothing calls this directly
no test coverage detected