Writing data to Yandex Object Storage
In Yandex Query, to write data to Yandex Object Storage buckets, you can use connections or bindings.
Example of writing JSON
data using bindings:
INSERT INTO `my_binding`
SELECT
"value" AS value, "name" AS name
FROM
$data;
For a list of supported formats and data compression algorithms, see Supported write formats.
Writing data using connections
It is convenient to write data using connections for prototyping and initial setup of data write operations. Before writing data to a bucket, create a connection to Object Storage and use the following SQL statement:
INSERT INTO <connection>.<path>
WITH
(
format='<data_format>',
compression='<compression_format>'
)
SELECT
<expression>
FROM
<query>
Where:
<connection>
: Name of the connection to Object Storage.<path>
: Path within the bucket to write data to.<query>
: Query data source query.
Example
Sample query to write data to Object Storage using connections:
INSERT INTO `connection`.`test/`
WITH
(
format='csv_with_names'
)
SELECT
"value" AS value, "name" AS name
Where:
connection
: Name of the connection to Object Storage.test/
: Path within the bucket to write data to.
Writing data using bindings
If you need to make data writes on a regular basis, it is handy to use bindings. This helps avoid entering all the details of handling this data in each query. Before writing data to a bucket, create a data binding in Object Storage and use the following SQL statement:
INSERT INTO `<binding>`
SELECT
<expression>
FROM
<query>
Where:
<binding>
: Name of a binding to Object Storage data.<query>
: Query data source query.
Example
Sample query to write data to Object Storage using bindings:
INSERT INTO `test`
SELECT
"value" AS value, "name" AS name
Where:
test
: Name of a binding to Object Storage data.
Supported write formats
Currently, the following data write formats are supported:
Data format | Name in Query |
---|---|
CSV |
csv_with_names |
Parquet |
parquet |
Query supports the following compression algorithms for data writes:
Compression format | Name in Query |
---|---|
Gzip |
gzip |
Zstd |
zstd |
LZ4 |
lz4 |
Brotli |
brotli |
Bzip2 |
bzip2 |
Xz |
xz |
Parquet
file format supports its own internal compression algorithms. Query allows writing data in parquet
format using the following compression algorithms:
Compression format | Name in Query |
---|---|
Snappy |
No name, by default |