Use multi-source pre-configured landscape and learn how to import data from an Amazon S3 bucket to SAP HANA Cloud, SAP HANA database.
One can use the IMPORT FROM and EXPORT INTO commands to work with single database objects in CSV and parquet formats.
IMPORT/EXPORT of files does not require additional temporary space as these commands buffer I/O directly from/into AWS S3.
Amazon Simple Storage Service (Amazon S3) An object storage service offering industry-leading scalability, data availability, security, and performance. S3 is built to store and retrieve any amount of data from anywhere. Data is stored as objects within resources called buckets, and a single object can be up to 5 terabytes in size.
Parquet Files Apache Parquet is an open source, column-oriented data file format designed for efficient data storage and retrieval. It provides efficient data compression and encoding schemes with enhanced performance to handle complex data in bulk.
Comma-Separated Value (CSV) Files CSV files are plain-text files, making them easier to read. Since they’re plain text, they’re easier to import into a spreadsheet or another storage database, regardless of the specific software you’re using.
Use the IMPORT FROM and EXPORT INTO commands to work with single database objects in CSV and Parquet formats. The basic syntax of the commands is shown here (using CSV format), the examples below illustrate the usage further:
1IMPORT FROM CSV FILE '<S3_path.csv>' INTO <TARGET_TABLE_NAME> [with options];1EXPORT INTO CSV FILE '<S3_path.csv>' FROM <SOURCE_TABLE_NAME> [with options];
1CREATE COLUMN TABLE S3_GX_CUSTOMERS AS (select * from HC_DEV.GX_CUSTOMERS);

12EXPORT S3_GX_CUSTOMERS AS PARQUET INTO
's3-eu-west-1://s3-ta-hc/{placeholder|userid}_GX_CUSTOMERS' WITH CREDENTIAL 'AWS_S3';
12import scan 's3-eu-west-1://s3-ta-hc/{placeholder|userid}_GX_CUSTOMERS'
WITH CREDENTIAL 'AWS_S3';
1select * from #IMPORT_SCAN_RESULT;
To import data from the S3 bucket, drop the S3_GX_CUSTOMERS table in local schema. The following SQL definition statement will either drop or rename source table to target table S3_GX_CUSTOMERS.
123-- drop table or rename table
-- drop table S3_GX_CUSTOMERS;
rename table S3_GX_CUSTOMERS to S3_GX_CUSTOMERS_OLD;
12345-- import s3 data
IMPORT S3_GX_CUSTOMERS AS PARQUET FROM 's3-eu-west-1://s3-ta-hc/{placeholder|userid}_GX_CUSTOMERS' WITH CREDENTIAL 'AWS_S3';
-- check row count
select count(*) from S3_GX_CUSTOMERS;
Well done!! This completes the lesson on the different options in SAP HANA Cloud, importing and exporting data from S3 cloud storage.