AWS Kinesis Firehose到Redshift的记录应如何格式化? [英] How should records be formatted for AWS Kinesis Firehose to Redshift?
本文介绍了AWS Kinesis Firehose到Redshift的记录应如何格式化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请考虑以下内容:
- Redshift中一个名为"people"的表,其中包含字段ID,名称和年龄
- 称为"people"的运动型流水流,配置为写入"people"表,并且"Redshift表列"的值为"id,name,age"
目前尚不清楚如何格式化数据" blob.这是一个代码示例,其中数据用制表符分隔:
It's not clear how to format the 'Data' blob. Here's an example of what the code looks like with the data separated by tabs:
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);
});
以下是我检查过的一些文档:
Here are some of the docs I have checked:
- 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/AWSJavaScriptSDK/latest/AWS/Firehose.html#putRecordBatch-property
- 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/AWSJavaScriptSDK/latest/AWS/Firehose.html#putRecordBatch-property
推荐答案
答案在这里:
http://docs.aws. amazon.com/redshift/latest/dg/copy-parameters-data-format.html
字段必须为管道'|'默认情况下分隔.行应该用换行符分隔.
Fields need to be pipe '|' separated by default. Rows should be separated by new lines.
更新后的更正代码:
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);
});
这篇关于AWS Kinesis Firehose到Redshift的记录应如何格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文