ReferenceSQL ReferenceAggregate Functions

groupFormat

Formats the rows in each group using the specified output format and returns the result as a string.

Formats the rows in each group using the specified output format and returns the result as a string.

The format name is passed as a parameter, and the arguments are the columns to format. Column names are generated as c1, c2, ... in the formatted output.

Syntax

groupFormat(format)(x, y, ...)

Parameters

  • format — Output format name. For example, JSONEachRow, CSV, TabSeparated. String

Arguments

  • x, y, ... — Expressions to format as rows. Any

Returned value

Formatted output for the group. String

Examples

Basic usage

SELECT groupFormat('JSONEachRow')(number, toString(number))
FROM numbers(3)
{"c1":0,"c2":"0"}
{"c1":1,"c2":"1"}
{"c1":2,"c2":"2"}