gpt4 book ai didi

amazon-web-services - AWS Kinesis Firehose到Redshift的记录应如何格式化?

转载 作者:行者123 更新时间:2023-12-04 17:33:22 27 4
gpt4 key购买 nike

考虑以下:

  • Redshift中的一个名为“people”的表,具有字段id,名称和年龄
  • 一种称为“people”的运动firehose流,配置为写入“people”表,并且“Redshift table columns”的值为“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/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

    字段必须为管道“|”默认情况下分隔。行之间应用新行分隔。

    更新后的更正代码:

    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);
    });

    关于amazon-web-services - AWS Kinesis Firehose到Redshift的记录应如何格式化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34485017/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com