

# ResolveChoice 类
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice"></a>

解析 `DynamicFrame` 内的选择类型。

## 示例
<a name="pyspark-ResolveChoice-example"></a>

我们建议您使用 [`DynamicFrame.resolveChoice()`](aws-glue-api-crawler-pyspark-extensions-dynamic-frame.md#aws-glue-api-crawler-pyspark-extensions-dynamic-frame-resolveChoice) 方法来处理 `DynamicFrame` 中包含多种类型的字段。要查看代码示例，请参阅 [示例：使用 resolveChoice 处理包含多种类型的列](aws-glue-api-crawler-pyspark-extensions-dynamic-frame.md#pyspark-resolveChoice-example)。

## 方法
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-_methods"></a>
+ [\$1\$1call\$1\$1](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-__call__)
+ [apply](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-apply)
+ [name](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-name)
+ [describeArgs](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeArgs)
+ [describeReturn](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeReturn)
+ [describeTransform](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeTransform)
+ [describeErrors](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeErrors)
+ [describe](#aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describe)

## \$1\$1call\$1\$1(frame, specs = none, choice = "", transformation\$1ctx = "", info = "", stageThreshold = 0, totalThreshold = 0)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-__call__"></a>

提供有关解析 `DynamicFrame` 内歧义类型的信息。它返回生成的 `DynamicFrame`。
+ `frame` – 在其中解析选择类型的 `DynamicFrame` (必需)。
+ `specs` – 要解析的特定歧义列表，每个歧义均采用元组形式：`(path, action)`。`path` 值标识特定歧义元素，`action` 值标识相应解析。

  只能使用 `spec` 和 `choice` 参数之一。如果 `spec` 参数不为 `None`，则 `choice` 参数必须为空字符串。反过来，如果 `choice` 不为空字符串，则 `spec` 参数必须为 `None`。如果两个参数均未提供，则 Amazon Glue 尝试解析架构并用它来解析歧义。

  `specs` 元组的 `action` 部分可以指定以下解析策略之一：
  + `cast` – 允许指定一种要强制转换到的类型（例如，`cast:int`）。
  + `make_cols` – 通过展平数据来解析潜在的歧义。例如，如果 `columnA` 是 `int` 或 `string`，则解析就是在结果 `DynamicFrame` 中生成名为 `columnA_int` 和 `columnA_string` 的两个列。
  + `make_struct` – 通过用一种结构表示数据来解析潜在的歧义。例如，如果某个列中的数据是 `int` 或 `string`，则使用 `make_struct` 操作会在结果 `DynamicFrame` 中生成结构列，而每个结构都同时包含 `int` 和 `string`。
  + `project` – 通过仅在结果 `DynamicFrame` 中保留指定类型的值来解析潜在的歧义。例如，如果 `ChoiceType` 列中的数据可以是 `int` 或 `string`，则指定 `project:string` 操作会从结果 `DynamicFrame` 中删除非 `string` 类型的值。

  如果 `path` 识别到数组，则在数组名称后放置一个空的方括号可避免歧义。例如，假设您正在使用结构如下的数据：

  ```
  "myList": [
    { "price": 100.00 },
    { "price": "$100.00" }
  ]
  ```

  可以通过将 `path` 设置为 `"myList[].price"`、将 `action` 设置为 `"cast:double"` 来选择价格的数字而非字符串版本。
+ `choice` – `specs` 参数为 `None` 时的默认解析操作。如果 `specs` 参数不为 `None`，则只能将此项设置为空字符串，不能设置为其他值。

  除了先前描述的 `specs` 操作外，此参数还支持以下操作：
  + `MATCH_CATALOG` – 尝试将每个 `ChoiceType` 转换为指定数据目录表中的对应类型。
+ `database` – 用于 `MATCH_CATALOG` 选择的 Amazon Glue Data Catalog 数据库（对于 `MATCH_CATALOG` 是必需的）。
+ `table_name` – 用于 `MATCH_CATALOG` 操作的 Amazon Glue Data Catalog 表名称（对于 `MATCH_CATALOG` 是必需的）。
+ `transformation_ctx` – 用于标识状态信息的唯一字符串 (可选)。
+ `info` – 与转换中的错误关联的字符串 (可选)。
+ `stageThreshold` – 在转换出错之前可能在其中发生的最大错误数（可选）。默认值为 0。
+ `totalThreshold` – 在处理出错之前可能全面发生的最大错误数（可选）。默认值为 0。

## apply(cls, \$1args, \$1\$1kwargs)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-apply"></a>

继承自 `GlueTransform` [apply](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-apply)。

## name(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-name"></a>

继承自 `GlueTransform` [名称](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-name)。

## describeArgs(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeArgs"></a>

继承自 `GlueTransform` [describeArgs](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeArgs)。

## describeReturn(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeReturn"></a>

继承自 `GlueTransform` [describeReturn](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeReturn)。

## describeTransform(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeTransform"></a>

继承自 `GlueTransform` [describeTransform](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeTransform)。

## describeErrors(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describeErrors"></a>

继承自 `GlueTransform` [describeErrors](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describeErrors)。

## describe(cls)
<a name="aws-glue-api-crawler-pyspark-transforms-ResolveChoice-describe"></a>

继承自 `GlueTransform` [describe](aws-glue-api-crawler-pyspark-transforms-GlueTransform.md#aws-glue-api-crawler-pyspark-transforms-GlueTransform-describe)。