Importing from Parquet
Before loading data, we can use file() function to explore an example parquet file structure:Importing to an existing table
Let’s create a table into which we’ll import Parquet data:FROM INFILE clause:
date column) to the Date type. This is because ClickHouse does a typecast automatically based on the types in the target table.
Inserting a local file to remote server
If you want to insert a local Parquet file to a remote ClickHouse server, you can do this by piping the contents of the file intoclickhouse-client, as shown below:
Creating new tables from Parquet files
Since ClickHouse reads parquet file schema, we can create tables on the fly:Exporting to Parquet format
To export any table or query result to the Parquet file, we can use anINTO OUTFILE clause:
export.parquet file in a working directory.
ClickHouse and Parquet data types
ClickHouse and Parquet data types are mostly identical but still differ a bit. For example, ClickHouse will exportDateTime type as a Parquets’ int64. If we then import that back to ClickHouse, we’re going to see numbers (time.parquet file):
Further reading
ClickHouse introduces support for many formats, both text, and binary, to cover various scenarios and platforms. Explore more formats and ways to work with them in the following articles:- CSV and TSV formats
- Avro, Arrow and ORC
- JSON formats
- Regex and templates
- Native and binary formats
- SQL formats