Amazon S3 Select can be used to filter the contents of an Amazon S3 object based on a simple structured query language (SQL) statement. The file name and data serialization format for the response must be specified as a metadata connector propery. Currently the connnector only supports the CSV file format.
BEGIN
CALL sysadmin.createConnection(
name
=>
'f1'
, jbossCLITemplateName =>
's3select'
,
connectionOrResourceAdapterProperties =>
'region=eu-west-1,keyId=AKIAIJLWFALNYVYFOEMQ,secretKey="---------------------------",'
||
'bucketName=my-bucket,'
||
'metadata="\"sample.csv\" (\"ID\":\"integer\", \"Product\":\"string\",\"Price\":\"double\")"'
);
CALL sysadmin.createDataSource(
name
=>
'f1'
, translator =>
's3select'
, modelProperties =>
''
, translatorProperties =>
''
);
END
;;
SELECT
*
FROM
f1.sample_csv;
Several files may be specified within a single data source:
CALL sysadmin.createConnection(
name
=>
'f2'
, jbossCLITemplateName =>
's3select'
,
connectionOrResourceAdapterProperties =>
'region=eu-west-1,keyId=AKIAIJLWFALNYVYFOEMQ,secretKey="---------------------------",'
||
'bucketName=my-bucket,'
||
'metadata="\"sample.csv\" (\"ID\":\"integer\", \"Product\":\"string\",\"Price\":\"double\")"'
||
' "\"sample2.csv\" (\"CustomerId\":\"integer\", \"CustomerName\":\"string\")"'
);
CALL sysadmin.createDataSource(
name
=>
'f2'
, translator =>
's3select'
, modelProperties =>
''
, translatorProperties =>
''
);
SELECT
*
FROM
f2.sample2_csv;