Integrating S3 with ClapDB
You can insert data from S3 into ClapDB.
S3 Table Functions
The s3 table function allows you to read files from S3 compatible storage. The outline for this syntax is:
where:
- path Bucket URL with a path to the file.
- format — The format of the file.
Preparation
To interact with our S3-based dataset, we prepare a standard table as our destination. The statement below creates a table named mgbench_logs2 in the default database:
Inserting Data from S3
To read and insert the data into our instance, We combine our s3 function with a simple INSERT statement to achieve this.
Note that we aren’t required to list our columns because our target table provides the required structure. This requires the columns to appear in the order specified in the table DDL statement: columns are mapped according to their position in the SELECT clause.
columns can also be mapped according to their names using ‘CSVWithNames’.
NOTE: the bucket clapdb-datasets-ap-south-1
is public readable, so we don’t need specify aws_access_key_id
and aws_secret_access_key
.