考虑以下:
- Redshift 中名为“people”的表,其中包含字段 id、姓名和年龄
- 名为“people”的 kinesis firehose 流,配置为写入“people”表,“Redshift 表列”的值为“id、name、age”
目前尚不清楚如何格式化“数据”blob。下面是代码的示例,其中数据由制表符分隔:
let AWS = require('aws-sdk');
let firehose = new AWS.Firehose();
let params = {
DeliveryStreamName: 'people',
// id,name,age
Records: [{Data: '4ccf6d3a-acdf-11e5-ad54-28cfe91fa8f1\tBob\tSmith'}]
};
firehose.putRecordBatch(params, (err, result) => {
console.log(err || result);
});
以下是我检查过的一些文档:
- http://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecordBatch.html http://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecordBatch.html
- http://docs.aws.amazon.com/firehose/latest/dev/writing-with-sdk.html http://docs.aws.amazon.com/firehose/latest/dev/writing-with-sdk.html
- http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Firehose.html#putRecordBatch-property http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Firehose.html#putRecordBatch-property
答案在这里:
http://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-format.html http://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-format.html
字段需要是管道“|”默认分开。行应该用新行分隔。
更新更正的代码:
let AWS = require('aws-sdk');
let firehose = new AWS.Firehose();
let params = {
DeliveryStreamName: 'people',
// id,name,age
Records: [{Data: '4ccf6d3a-acdf-11e5-ad54-28cfe91fa8f1|Bob|Smith\n'}]
};
firehose.putRecordBatch(params, (err, result) => {
console.log(err || result);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)