【问题标题】:AWS DMS SQL Server to s3 parquet - change-data-type transformation rule and 'Parquet type not supported: INT32 (UINT_8)'AWS DMS SQL Server 到 s3 parquet - 更改数据类型转换规则和“不支持 Parquet 类型:INT32 (UINT_8)”
【发布时间】:2020-05-26 08:11:26
【问题描述】:

我们使用 AWS DMS 将 SQL Server 数据库作为 parquet 文件转储到 S3 中。想法是在镶木地板上运行一些带有火花的分析。完全加载完成后,将无法读取镶木地板,因为它们在架构中有 UINT 字段。 Spark 拒绝使用Parquet type not supported: INT32 (UINT_8) 阅读它们。我们使用转换规则来覆盖UINT 列的数据类型。但看起来它们没有被 DMS 引擎拾取。为什么?

有许多规则,如“将单位转换为 int”,见下文(注意 UINT1 是 1 字节无符号 DMS DataTypes):

{
  "rule-type": "transformation",
  "rule-id": "7",
  "rule-name": "uintToInt",
  "rule-action": "change-data-type",
  "rule-target": "column",
  "object-locator": {
    "schema-name": "%",
    "table-name": "%",
    "column-name": "%",
    "data-type": "uint1"
  },
  "data-type": {
    "type": "int4"
  }
}

S3 DataFormat=parquet;ParquetVersion=parquet_2_0 和 DMS 引擎版本是 3.3.2

但是仍然使用 uint 获取 parquet 模式。见下文:

id: int32
name: string
value: string
status: uint8

尝试使用 spark 阅读这样的镶木地板给了我

org.apache.spark.sql.AnalysisException: Parquet type not supported: INT32 (UINT_8);
    at org.apache.spark.sql.execution.datasources.parquet.ParquetToSparkSchemaConverter.typeNotSupported$1(ParquetSchemaConverter.scala:100)
    at org.apache.spark.sql.execution.datasources.parquet.ParquetToSparkSchemaConverter.convertPrimitiveField(ParquetSchemaConverter.scala:136)

为什么没有触发 DMS 转换规则?

【问题讨论】:

  • 我遇到了限制吗? Changes to the source table structure during full load are not supporteddocs.aws.amazon.com/dms/latest/userguide/CHAP_Target.S3.html
  • 您知道如何完成这项工作吗?谢谢。
  • @Anton 你还在面对这个问题吗?我使用了下面提出的解决方案并且它有效(我将更改应用于所有模式-%):{“rule-type”:“transformation”,“rule-id”:“2”,“rule-name”:“uint1 -to-int4", "rule-action": "change-data-type", "rule-target": "column", "object-locator": { "schema-name": "%", "table-名称”:“%”,“列名称”:“%”,“数据类型”:“uint1”},“数据类型”:{“类型”:“int1”}}
  • @dp6000,自从 DMS 3.3.2 以来我没有尝试过,我们放弃了 DMS 以支持其他解决方案

标签: apache-spark amazon-s3 aws-dms


【解决方案1】:

在 DMS 上将数据直接从 UINT 转换为 INT 可解决此问题。 您的映射规则应如下所示:

{
"rules": [
    ...
    {
        "rule-type": "transformation",
        "rule-id": "2",
        "rule-name": "unit1-to-int1",
        "rule-action": "change-data-type",
        "rule-target": "column",
        "object-locator": {
            "schema-name": "schema",
            "table-name": "%",
            "column-name": "%",
            "data-type": "uint1"
        },
        "data-type": {
            "type": "int1"
        }
    },
    {
        "rule-type": "transformation",
        "rule-id": "3",
        "rule-name": "unit2-to-int2",
        "rule-action": "change-data-type",
        "rule-target": "column",
        "object-locator": {
            "schema-name": "schema",
            "table-name": "%",
            "column-name": "%",
            "data-type": "uint2"
        },
        "data-type": {
            "type": "int2"
        }
    },
    {
        "rule-type": "transformation",
        "rule-id": "4",
        "rule-name": "unit4-to-int4",
        "rule-action": "change-data-type",
        "rule-target": "column",
        "object-locator": {
            "schema-name": "schema",
            "table-name": "%",
            "column-name": "%",
            "data-type": "uint4"
        },
        "data-type": {
            "type": "int4"
        }
    },
    {
        "rule-type": "transformation",
        "rule-id": "5",
        "rule-name": "unit8-to-int8",
        "rule-action": "change-data-type",
        "rule-target": "column",
        "object-locator": {
            "schema-name": "schema",
            "table-name": "%",
            "column-name": "%",
            "data-type": "uint8"
        },
        "data-type": {
            "type": "int8"
        }
    }
]}

文档:https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.html#CHAP_Tasks.CustomizingTasks.TableMapping.SelectionTransformation.Transformations

【讨论】:

  • 您能分享您尝试迁移的表架构和映射规则吗?
  • 我在 SQL Server DB 中有 smallint 类型的列。我尝试了各种组合将 intX 转换为 uintX (请检查问题中的示例),但看起来它忽略了它。正如我所提到的,我可能会达到这个限制docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.S3.htmlChanges to the source table structure during full load are not supported。顺便提一句。您的示例将 uint 转换为 int,不是吗?我需要其他方式。
【解决方案2】:

我能够在镶木地板文件上进行转换的唯一方法是指定要转换的确切列。比如:

{
   "rules": [
   ...
   {
    "rule-type": "transformation",
    "rule-id": "2",
    "rule-name": "unit1-to-int1",
    "rule-action": "change-data-type",
    "rule-target": "column",
    "object-locator": {
        "schema-name": "acessa",
        "table-name": "<table_name>",
        "column-name": "<column_name>"
    },
    "data-type": {
        "type": "int1"
    }
   }
  ]
}

在对象定位器中使用通配符 % 作为列名不起作用

【讨论】:

  • 谢谢,不过我有 6K 表,这样做不太实际
【解决方案3】:

如果您需要选择特定列并将所有 UINTS 转换为 INTS,则无法专门命名要转换的列。如果您进行通配符数据类型转换,它将包括覆盖您的列选择并包括所有列。

【讨论】:

  • 谢谢,不过我有 6K 表,这样做不太实际
猜你喜欢
  • 1970-01-01
  • 2018-12-14
  • 1970-01-01
  • 2018-10-27
  • 2019-02-15
  • 2018-07-13
  • 2016-09-27
  • 1970-01-01
  • 2019-09-27
相关资源
最近更新 更多