Reading data from Object Storage using Query bindings
There are cases when you need to run the same data queries on a regular basis. To avoid entering all the details of handling this data each time you make a query, you can use bindings.
Sample data read query using bindings:
SELECT
*
FROM
`logs`
WHERE
version>1
Setting up a data binding
To create a binding to read data from Object Storage:
-
In the management console
, select the folder where you want to create a binding. -
In the list of services, select Yandex Query.
-
In the left-hand panel, go to the Bindings tab.
-
Click
Create. -
Under Connection parameters:
- In the Type field, select
Object Storage
. - In the Connection field, select an existing connection or create a new one.
- In the Type field, select
-
Under Binding parameters:
-
In the Name field, specify the binding name.
-
In the Path field, specify the path to bucket data. Parts of file names can be specified using
/*
, such asyellow/*.csv
. -
In the Compression field, specify the data compression method.
-
In the Format field, specify the format of stored data.
-
Select a partitioning mode and list partitioning columns and their types.
If you are using the Extended mode, specify the partition projection columns.
-
List data columns and their types.
Alternatively, you can click Detect columns to do this automatically.
-
-
To check the data, click Preview.
-
Click Create.
Data model
Object Storage stores data as binary files. To read data, use the following SQL statement:
SELECT
<expression>
FROM
`<binding>`
WHERE
<filter>;
Where:
<binding>
: Name of the previously created data binding.
Example of reading data using bindings
Sample query to read data from Object Storage using bindings:
SELECT
*
FROM
`binding_name`
Where binding_name
is the data binding name in Object Storage.