mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
2.0 KiB
2.0 KiB
slug | sidebar_position | sidebar_label |
---|---|---|
/en/sql-reference/table-functions/format | 56 | format |
format
Extracts table structure from data and parses it according to specified input format.
Syntax
format(format_name, data)
Parameters
format_name
— The format of the data.data
— String literal or constant expression that returns a string containing data in specified format
Returned value
A table with data parsed from data
argument according specified format and extracted schema.
Examples
Query:
:) select * from format(JSONEachRow,
$$
{"a": "Hello", "b": 111}
{"a": "World", "b": 123}
{"a": "Hello", "b": 112}
{"a": "World", "b": 124}
$$)
Result:
┌───b─┬─a─────┐
│ 111 │ Hello │
│ 123 │ World │
│ 112 │ Hello │
│ 124 │ World │
└─────┴───────┘
Query:
:) desc format(JSONEachRow,
$$
{"a": "Hello", "b": 111}
{"a": "World", "b": 123}
{"a": "Hello", "b": 112}
{"a": "World", "b": 124}
$$)
Result:
┌─name─┬─type──────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ b │ Nullable(Float64) │ │ │ │ │ │
│ a │ Nullable(String) │ │ │ │ │ │
└──────┴───────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
See Also