跳到主要内容
跳到主要内容
编辑此页

输入和输出数据格式

ClickHouse 可以接受和返回多种格式的数据。支持输入的格式可用于解析提供给 INSERT 的数据,执行从文件支持的表(如 File、URL 或 HDFS)的 SELECT,或读取字典。支持输出的格式可用于排列 SELECT 的结果,以及执行到文件支持的表的 INSERT。所有格式名称都不区分大小写。

支持的格式有

格式输入输出
TabSeparated
TabSeparatedRaw
TabSeparatedWithNames
TabSeparatedWithNamesAndTypes
TabSeparatedRawWithNames
TabSeparatedRawWithNamesAndTypes
Template
TemplateIgnoreSpaces
CSV
CSVWithNames
CSVWithNamesAndTypes
CustomSeparated
CustomSeparatedWithNames
CustomSeparatedWithNamesAndTypes
SQLInsert
Values
Vertical
JSON
JSONAsString
JSONAsObject
JSONStrings
JSONColumns
JSONColumnsWithMetadata
JSONCompact
JSONCompactStrings
JSONCompactColumns
JSONEachRow
PrettyJSONEachRow
JSONEachRowWithProgress
JSONStringsEachRow
JSONStringsEachRowWithProgress
JSONCompactEachRow
JSONCompactEachRowWithNames
JSONCompactEachRowWithNamesAndTypes
JSONCompactStringsEachRow
JSONCompactStringsEachRowWithNames
JSONCompactStringsEachRowWithNamesAndTypes
JSONObjectEachRow
BSONEachRow
TSKV
Pretty
PrettyNoEscapes
PrettyMonoBlock
PrettyNoEscapesMonoBlock
PrettyCompact
PrettyCompactNoEscapes
PrettyCompactMonoBlock
PrettyCompactNoEscapesMonoBlock
PrettySpace
PrettySpaceNoEscapes
PrettySpaceMonoBlock
PrettySpaceNoEscapesMonoBlock
Prometheus
Protobuf
ProtobufSingle
ProtobufList
Avro
AvroConfluent
Parquet
ParquetMetadata
Arrow
ArrowStream
ORC
One
Npy
RowBinary
RowBinaryWithNames
RowBinaryWithNamesAndTypes
RowBinaryWithDefaults
Native
Null
XML
CapnProto
LineAsString
Regexp
RawBLOB
MsgPack
MySQLDump
DWARF
Markdown
Form

您可以使用 ClickHouse 设置来控制某些格式处理参数。有关更多信息,请阅读设置部分。

TabSeparated

请参阅 TabSeparated

TabSeparatedRaw

请参阅 TabSeparatedRaw

TabSeparatedWithNames

请参阅 TabSeparatedWithNames

TabSeparatedWithNamesAndTypes

请参阅 TabSeparatedWithNamesAndTypes

TabSeparatedRawWithNames

请参阅 TabSeparatedRawWithNames

TabSeparatedRawWithNamesAndTypes

请参阅 TabSeparatedRawWithNamesAndTypes

Template

请参阅 Template

TemplateIgnoreSpaces

请参阅 TemplateIgnoreSpaces

TSKV

请参阅 TSKV

CSV

请参阅 CSV

CSVWithNames

请参阅 CSVWithNames

CSVWithNamesAndTypes

请参阅 CSVWithNamesAndTypes

CustomSeparated

请参阅 CustomSeparated

CustomSeparatedWithNames

请参阅 CustomSeparatedWithNames

CustomSeparatedWithNamesAndTypes

请参阅 CustomSeparatedWithNamesAndTypes

SQLInsert

请参阅 SQLInsert

JSON

请参阅 JSON

JSONStrings

请参阅 JSONStrings

JSONColumns

请参阅 JSONColumns

JSONColumnsWithMetadata

请参阅 JSONColumnsWithMetadata

JSONAsString

请参阅 JSONAsString

JSONAsObject

请参阅 JSONAsObject

JSONCompact

请参阅 JSONCompact

JSONCompactStrings

请参阅 JSONCompactStrings

JSONCompactColumns

请参阅 JSONCompactColumns

JSONEachRow

请参阅 JSONEachRow

PrettyJSONEachRow

请参阅 PrettyJSONEachRow

JSONStringsEachRow

请参阅 JSONStringsEachRow

JSONCompactEachRow

请参阅 JSONCompactEachRow

JSONCompactStringsEachRow

请参阅 JSONCompactStringsEachRow

JSONEachRowWithProgress

请参阅 JSONEachRowWithProgress

JSONStringsEachRowWithProgress

请参阅 JSONStringsEachRowWithProgress

JSONCompactEachRowWithNames

请参阅 JSONCompactEachRowWithNames

JSONCompactEachRowWithNamesAndTypes

请参阅 JSONCompactEachRowWithNamesAndTypes

JSONCompactStringsEachRowWithNames

请参阅 JSONCompactStringsEachRowWithNames

JSONCompactStringsEachRowWithNamesAndTypes

请参阅 JSONCompactStringsEachRowWithNamesAndTypes

JSONObjectEachRow

请参阅 JSONObjectEachRow

JSON 格式设置

请参阅 JSON 格式设置

BSONEachRow

请参阅 BSONEachRow

Native

请参阅 Native

Null

请参阅 Null

Pretty

请参阅 Pretty

PrettyNoEscapes

请参阅 PrettyNoEscapes

PrettyMonoBlock

请参阅 PrettyMonoBlock

PrettyNoEscapesMonoBlock

请参阅 PrettyNoEscapesMonoBlock

PrettyCompact

请参阅 PrettyCompact

PrettyCompactNoEscapes

请参阅 PrettyCompactNoEscapes

PrettyCompactMonoBlock

请参阅 PrettyCompactMonoBlock

PrettyCompactNoEscapesMonoBlock

请参阅 PrettyCompactNoEscapesMonoBlock

PrettySpace

请参阅 PrettySpace

PrettySpaceNoEscapes

请参阅 PrettySpaceNoEscapes

PrettySpaceMonoBlock

请参阅 PrettySpaceMonoBlock

PrettySpaceNoEscapesMonoBlock

请参阅 PrettySpaceNoEscapesMonoBlock

RowBinary

请参阅 RowBinary

RowBinaryWithNames

请参阅 RowBinaryWithNames

RowBinaryWithNamesAndTypes

请参阅 RowBinaryWithNamesAndTypes

RowBinaryWithDefaults

请参阅 RowBinaryWithDefaults

Values

请参阅 Values

Vertical

请参阅 Vertical

XML

请参阅 XML

CapnProto

请参阅 CapnProto

Prometheus

请参阅 Prometheus

Protobuf

请参阅 Protobuf

ProtobufSingle

请参阅 ProtobufSingle

ProtobufList

请参阅 ProtobufList

Avro

请参阅 Avro

AvroConfluent

请参阅 AvroConfluent

Parquet

请参阅 Parquet

ParquetMetadata

请参阅 ParquetMetadata

Arrow

请参阅 Arrow

ArrowStream

请参阅 ArrowStream

ORC

请参阅 ORC

One

请参阅 One

Npy

请参阅 Npy

LineAsString

请参阅 LineAsString

另请参阅:LineAsStringWithNames, LineAsStringWithNamesAndTypes

Regexp

请参阅 Regexp

格式 Schema

包含格式 schema 的文件名由设置 format_schema 设置。当使用 Cap'n ProtoProtobuf 格式之一时,需要设置此设置。格式 schema 是文件名和此文件中的消息类型名称的组合,以冒号分隔,例如 schemafile.proto:MessageType。如果文件具有格式的标准扩展名(例如,Protobuf.proto),则可以省略它,在这种情况下,格式 schema 看起来像 schemafile:MessageType

如果您通过客户端在交互模式下输入或输出数据,则格式 schema 中指定的文件名可以包含绝对路径或相对于客户端当前目录的路径。如果您在批处理模式下使用客户端,则由于安全原因,schema 的路径必须是相对路径。

如果您通过HTTP 接口输入或输出数据,则格式 schema 中指定的文件名应位于服务器配置中的format_schema_path中指定的目录中。

跳过错误

某些格式(如 CSVTabSeparatedTSKVJSONEachRowTemplateCustomSeparatedProtobuf)可以在发生解析错误时跳过损坏的行,并从下一行的开头继续解析。请参阅 input_format_allow_errors_numinput_format_allow_errors_ratio 设置。限制

  • 如果发生解析错误,JSONEachRow 会跳过所有数据,直到新行(或 EOF),因此行必须以 \n 分隔才能正确计数错误。
  • TemplateCustomSeparated 在最后一列之后和行之间使用分隔符来查找下一行的开头,因此仅当它们中至少一个不为空时,跳过错误才有效。

RawBLOB

请参阅 RawBLOB

Markdown

请参阅 Markdown

MsgPack

请参阅 MsgPack

MySQLDump

请参阅 MySQLDump

DWARF

请参阅 Dwarf

Form

请参阅 Form