External tables
Some external data sources, such as database management systems, store data in a structured format, while others, like S3 (Yandex Object Storage), store data as individual files. To work with file-based data sources, you need to understand both the file placement rules and the formats of the stored data.
A special entity, EXTERNAL TABLE,
describes the stored data in such sources. External tables allow you to define the schema of the stored files and the schema of file placement within the source.
A record in YQL might look like this:
CREATE EXTERNAL TABLE s3_test_data (
key Utf8 NOT NULL,
value Utf8 NOT NULL
) WITH (
DATA_SOURCE="bucket",
LOCATION="folder",
FORMAT="csv_with_names",
COMPRESSION="gzip"
);
Data can be inserted into external tables just like regular tables. For example, to write data to an external table, you need to execute the following query:
INSERT INTO s3_test_data
SELECT * FROM Table
More details on working with external tables describing S3 buckets (Object Storage) can be found in section Reading data from an external table pointing to S3 (Object Storage).