Data formats and compression algorithms
Below you will find the data formats and compression algorithms supported in Yandex Query.
Supported data formats
Yandex Query Language supports the following data formats:
Csv_with_names
This format is based on the CSV
Sample data:
Year,Manufacturer,Model,Price
1997,Ford,E350,3000.00
1999,Chevy,"Venture «Extended Edition»",4900.00
Query example
SELECT
*
FROM <connection>.<path>
WITH
(
format=csv_with_names,
SCHEMA
(
Year int,
Manufacturer string,
Model string,
Price double
)
)
Query results:
| # | Manufacturer | Model | Price | Year |
|---|---|---|---|---|
| 1 | Ford | E350 | 3000 | 1997 |
| 2 | Chevy | Venture «Extended Edition» | 4900 | 1999 |
Tsv_with_names
This format is based on the TSV0x9)-separated columns with the first row containing column names.
Sample data:
Year Manufacturer Model Price
1997 Ford E350 3000.00
1999 Chevy "Venture «Extended Edition»" 4900.00
Query example
SELECT
*
FROM <connection>.<path>
WITH
(
format=tsv_with_names,
SCHEMA
(
Year int,
Manufacturer string,
Model string,
Price double
)
)
Query results:
| # | Manufacturer | Model | Price | Year |
|---|---|---|---|---|
| 1 | Ford | E350 | 3000 | 1997 |
| 2 | Chevy | Venture «Extended Edition» | 4900 | 1999 |
Json_list
This format is based on the JSON
Example of valid data presented as a list of JSON objects:
[
{ "Year": 1997, "Manufacturer": "Ford", "Model": "E350", "Price": 3000.0 },
{ "Year": 1999, "Manufacturer": "Chevy", "Model": "Venture «Extended Edition»", "Price": 4900.00 }
]
Example of invalid data: each line contains a separate JSON object, but these objects are not combined into a list:
{ "Year": 1997, "Manufacturer": "Ford", "Model": "E350", "Price": 3000.0 }
{ "Year": 1999, "Manufacturer": "Chevy", "Model": "Venture «Extended Edition»", "Price": 4900.00 }
Json_each_row
This format is based on the JSON
Example of valid data: each line contains a separate JSON object, without wrapping them into a list:
{ "Year": 1997, "Manufacturer": "Ford", "Model": "E350", "Price": 3000.0 },
{ "Year": 1999, "Manufacturer": "Chevy", "Model": "Venture «Extended Edition»", "Price": 4900.00 }
Query example
SELECT
*
FROM <connection>.<path>
WITH
(
format=json_each_row,
SCHEMA
(
Year int,
Manufacturer string,
Model string,
Price double
)
)
Query results:
| # | Manufacturer | Model | Price | Year |
|---|---|---|---|---|
| 1 | Ford | E350 | 3000 | 1997 |
| 2 | Chevy | Venture «Extended Edition» | 4900 | 1999 |
Raw
This format allows reading file contents in raw form. This data can then be split into rows and columns and processed via YQL
Use this format when Yandex Query‘s built-in data parsing capabilities are insufficient.
Query example
SELECT
*
FROM <connection>.<path>
WITH
(
format=raw,
SCHEMA
(
Data String
)
)
Query results:
Year,Manufacturer,Model,Price
1997,Ford,E350,3000.00
1999,Chevy,\"Venture «Extended Edition»\",4900.00
Json_as_string
This format is based on the JSON
With this format, each file must contain:
- Valid JSON object on each individual line of the file.
- Valid JSON objects wrapped in a list.
Example of valid data presented as a list of JSON objects:
{ "Year": 1997, "Manufacturer": "Ford", "Model": "E350", "Price": 3000.0 }
{ "Year": 1999, "Manufacturer": "Chevy", "Model": "Venture «Extended Edition»", "Price": 4900.00 }
Query example
SELECT
*
FROM <connection>.<path>
WITH
(
format=json_as_string,
SCHEMA
(
Data Json
)
)
Query results:
| # | Data |
|---|---|
| 1 | {"Manufacturer": "Ford", "Model": "E350", "Price": 3000, "Year": 1997} |
| 2 | {"Manufacturer": "Chevy", "Model": "Venture «Extended Edition»", "Price": 4900, "Year": 1999} |
Parquet
This format allows you to read the contents of Apache Parquet
Data compression algorithms supported in Parquet files:
- No compression
- SNAPPY
- GZIP
- LZO
- BROTLI
- LZ4
- ZSTD
- LZ4_RAW
Query example
SELECT
*
FROM <connection>.<path>
WITH
(
format=parquet,
SCHEMA
(
Year int,
Manufacturer string,
Model string,
Price double
)
)
Query results:
| # | Manufacturer | Model | Price | Year |
|---|---|---|---|---|
| 1 | Ford | E350 | 3000 | 1997 |
| 2 | Chevy | Venture «Extended Edition» | 4900 | 1999 |
Data reading example
Sample query for reading data from Yandex Object Storage.
SELECT
*
FROM
connection.`folder/filename.csv`
WITH(
format='csv_with_names',
SCHEMA
(
Year int,
Manufacturer String,
Model String,
Price Double
)
);
Where:
| Field | Description |
|---|---|
connection |
Yandex Object Storage connection name |
folder/filename.csv |
File path within the Yandex Object Storage bucket |
SCHEMA |
Data schema description in the file |
Supported compression algorithms
Reads
Yandex Query supports the following compression algorithms for reading data:
| Compression format | Name in Query |
|---|---|
| Gzip |
gzip |
| Zstd |
zstd |
| LZ4 |
lz4 |
| Brotli |
brotli |
| Bzip2 |
bzip2 |
| Xz |
xz |
While the parquet format supports built-in compression algorithms, Yandex Query also enables you to write parquet data using these:
| Compression format | Name in Query |
|---|---|
| Raw |
raw |
| Snappy |
snappy |
Writing to Yandex Object Storage
The service currently supports the following formats for writing data:
| Data format | Name in Query |
|---|---|
| CSV |
csv_with_names |
| Parquet |
parquet |
Query supports the following compression algorithms for writing data:
| Compression format | Name in Query |
|---|---|
| Gzip |
gzip |
| Zstd |
zstd |
| LZ4 |
lz4 |
| Brotli |
brotli |
| Bzip2 |
bzip2 |
| Xz |
xz |
While the parquet format supports built-in compression algorithms, Query also enables you to write parquet data using these:
| Compression format | Name in Query |
|---|---|
| Snappy |
None (used by default) |
Writing to Yandex Data Streams
Data Streams only lets you write data as a byte stream, which is processed by the receiving side.
When writing to Data Streams, file format and compression algorithm settings are not applied.