amazon-web-services - 如何在CDK中添加SerDe参数?

标签 amazon-web-services aws-glue aws-cdk aws-glue-data-catalog

我正在使用 CDK 创建这样的 Glue 表:

  const someTable = new Glue.Table(
      scope,
      "some-table",
      {
        tableName: "some-table",
        columns: [
          {
            name: "value",
            type: Glue.Schema.DOUBLE,
          },
          {
            name: "user_id",
            type: Glue.Schema.STRING,
          },
        ],
        partitionKeys: [
          {
            name: "region_id",
            type: Glue.Schema.BIG_INT,
          },
        ],
        database: glueDb,
        dataFormat: Glue.DataFormat.PARQUET,
        bucket: props.bucket,
      }
    );

看起来这正在按预期创建我的 Glue 表,但它也在幕后做一些事情,比如设置一个 Serde 序列化库 (org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe ).对于我的用例,我还必须在表配置中指定一些 Serde 参数,但我无法在 CDK 文档 (https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-glue.Table.html) 中找到如何执行此操作,即使它看起来像您可以在控制台中配置的内容“编辑表格”。

enter image description here

有没有人遇到过这个问题并对如何更新有任何建议?

谢谢!

最佳答案

将 serde 设置传递给 Table (@aws-cdk/aws-glue-alpha) 使用 dataFormat(DataFormat 类型)prop。

// TableProps
{
  dataFormat:  glue.DataFormat.PARQUET
}

要进行更细粒度的控制,请使用 L1 CfnTable (aws-cdk-lib) 构造,其 API 与 CloudFormation AWS::Glue::Table 匹配资源。

// CfnTableProps
tableInput: {
  // ...
  storageDescriptor: {
    inputFormat: 'org.apache.hadoop.mapred.TextInputFormat',
    outputFormat: 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat',
    serdeInfo: {
      serializationLibrary: 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe',
      parameters: { 'serialization.format': 1 },
    },

关于amazon-web-services - 如何在CDK中添加SerDe参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71213512/

相关文章:

android - AWS Android SDK 连接超时和重试

amazon-web-services - 云锋 : The request could not be satisfied

amazon-web-services - AWS Lambda 中的可视化配置 View 在哪里?

performance - 如何提高 AWS Glue 的性能?

python - 如何使用 aws CDK 和 Python 部署层并将其附加到 aws lambda 函数

aws-lambda - 资源处理程序返回消息 : "Invalid request provided: Updating PackageType is not supported"

amazon-web-services - AWS Beanstalk 和 SES 身份验证

amazon-web-services - 为什么我的 awsglue 作业仅使用一个执行程序和驱动程序?

amazon-web-services - 使用 AWS Glue Crawler 指定 SerDe 序列化库

aws-cdk - 传入模板参数