

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 支持的数据类型和值


Amazon Quick Sight 目前支持以下原始数据类型：`Date``Decimal`、`Integer`、和。`String`SPICE 支持以下数据集类型：`Date`、`Decimal-fixed`、`Decimal-float`、`Integer` 和 `String`。Quick Sight 通过将布尔值提升为整数来接受布尔值。它还可以派生地理空间数据类型。地理空间数据类型使用元数据来解释物理数据类型。经度和纬度都是数字。所有其他地理空间类别都是字符串。

确保用作数据来源的任何表或文件仅包含可隐式转换为这些数据类型的字段。Amazon Quick Sight 会跳过任何无法转换的字段或列。如果您收到错误消息，显示“fields were skipped because they use unsupported data types”，请更改您的查询或表以删除或重新转换不支持的数据类型。

## 字符串和文本数据


包含字符的字段或列称为*字符串*。数据类型为 `STRING` 的字段最初几乎可以包含任何类型的数据。示例包括姓名、描述、电话号码、账号、JSON 数据、城市、邮政编码、日期和可用于计算的数字。这些类型有时称为一般意义上的文本数据，但不是技术意义上的。Quick Sight 不支持数据集列中的二进制和字符大对象 (BLOBs)。在 Quick Sight 文档中，“文本” 一词始终表示 “字符串数据”。

首次查询或导入数据时，Quick Sight 会尝试将其标识为其他类型的数据，例如日期和数字。最好验证分配给字段或列的数据类型是否正确。

对于导入数据中的每个字符串字段，Quick Sight 使用 8 字节的字段长度加上 UTF-8 编码的字符长度。Amazon Quick Sight 支持 UTF-8 文件编码，但不支持 UTF-8（带有 BOM）。

## 日期和时间数据


数据类型为 `Date` 的字段还包括时间数据，也称为 `Datetime` 字段。Quick Sight 支持使用[支持的日期格式的日期](#supported-date-formats)和时间。

Quick Sight 使用 UTC 时间来查询、筛选和显示日期数据。当日期数据未指定时区时，Quick Sight 会采用 UTC 值。当日期数据确实指定了时区时，Quick Sight 会将其转换为以 UTC 时间显示。例如，具有类似时区偏移量的日期字段会转换**2015-11-01T03:00:00-08:00**为 UTC，并在 Amazon Quick Sight 中显示为**2015-11-01T15:30:00**。

对于导入数据中的每个`DATE`字段，Quick Sight 使用的字段长度为 8 字节。Quick Sight 支持 UTF-8 文件编码，但不支持 UTF-8（带有 BOM）。

## 数值数据


数值数据包括整数和小数。数据类型为 `INT` 的整数是没有小数位的负数或正数。Quick Sight 不区分大整数和小整数。值大于 `9007199254740991` 或 `2^53 - 1` 的整数可能无法在视觉对象中精确或正确显示。

数据类型为 `Decimal` 的小数是负数或正数，在小数点之前或之后至少包含一个小数位。当您选择直接查询模式时，所有非整数十进制类型都会标记为 `Decimal`，底层引擎会根据数据来源支持的行为处理数据点的精度。有关受支持的数据来源类型的更多信息，请参阅 [支持的数据类型和值](#supported-data-types-and-values)。

在中存储数据集时SPICE，可以选择将十进制值存储为十进制类型`fixed`或`float`十进制类型。 `Decimal-fixed`数据类型使用十进制 (`18,4`) 格式，允许总共允许 18 位数字，小数点后最多允许 4 位数字。 `Decimal-fixed`数据类型是进行精确数学运算的不错选择，但是 Quick Sight 会将值四舍五入到最接近的万分之一位。SPICE

`Decimal-float` 数据类型为值提供大约 16 位有效数字精度。有效数字可以位于小数点的任意一侧，以同时支持具有许多小数位和更高数字的数字。例如，`Decimal-float` 数据类型支持数字 `12345.1234567890` 或数字 `1234567890.12345`。如果您使用接近 `0` 的非常小的数字，则 `Decimal-float` 数据类型最多支持小数点右侧 15 位数字，例如 `0.123451234512345`。此数据类型支持的最大值为 `1.8 * 10^308`，以最大限度地降低数据集发生溢出错误的可能性。

`Decimal-float` 数据类型不精确，有些值存储为近似值，而不是实际值。这可能会导致在存储和返回某些特定值时出现轻微差异。以下注意事项适用于 `Decimal-float` 数据类型。
+ 如果您使用的数据集来自 Amazon S3 数据来源，SPICE 会为所有数字十进制值分配 `Decimal-float` 十进制类型。
+ 如果您使用的数据集来自数据库，SPICE 将使用数据库中为该值分配的十进制类型。例如，如果数据库中为该值分配了定点数值，则该值在 SPICE 中将为 `Decimal-fixed` 类型。

对于包含可转换为 `Decimal-float` 数据类型的字段的现有 SPICE 数据集，**编辑数据集**页面中会出现一个弹出窗口。要将现有数据集的字段转换为 `Decimal-float` 数据类型，请选择**更新字段**。如果不想选择加入，请选择**不更新字段**。每次打开**编辑数据集**页面时，都会弹出**更新字段**，直到保存并发布数据集为止。

## 外部数据来源支持的数据类型


下表列出了在 Amazon Quick Sight 中使用以下数据源时所支持的数据类型。


****  

| 数据库引擎或源 | 数值数据类型 | 字符串数据类型 | 日期时间类型 | 布尔数据类型 | 
| --- | --- | --- | --- | --- | 
|   **Amazon Athena、Presto、Starburst、Trino**  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  | 
|  **Amazon Aurora**、**MariaDB** 和 **MySQL**  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  | 
|   **亚马逊 OpenSearch 服务**  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  | 
|  **Oracle**  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html) | [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html) | [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html) | bit | 
|   **PostgreSQL**   |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  | 
|   **Apache Spark**  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  | 
|   **Snowflake**   |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  | 
|   **Microsoft SQL Server**   |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  | 

### 支持的日期格式


Amazon Quick Sight 支持本节中描述的日期和时间格式。在向 Amazon Quick Sight 添加数据之前，请检查您的日期格式是否兼容。如果您需要使用不支持的格式，请参阅 [使用不支持的日期或自定义日期](using-unsupported-dates.md)。

支持的格式因数据来源类型而异，如下所示：


| 数据来源 | 小时制 | 日期格式 | 
| --- | --- | --- | 
|  文件上传 Amazon S3 源 Athena Salesforce  |  24 小时和 12 小时制  |  Joda API 文档中描述了支持的日期和时间格式。 如需查看 Joda 日期格式的完整列表，请参阅 Joda DateTimeFormat 网站上的 [Class](http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html)。 对于存储在内存中的数据集 (SPICE)，Amazon Quick Sight 支持以下范围内的日期：`Jan 1, 0001 00:00:00 UTC`到`Dec 31, 9999, 23:59:59 UTC`。  | 
|  关系数据库源  |  仅限 24 小时制  |  以下数据和时间格式： [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/quick/latest/userguide/supported-data-types-and-values.html)  | 

### 不支持的数据值


如果某个字段包含的值与 Amazon Quick Sight 分配给该字段的数据类型不一致，则会跳过包含这些值的行。例如，使用以下源数据。

```
Sales ID    Sales Date    Sales Amount
--------------------------------------
001        10/14/2015        12.43
002        5/3/2012          25.00
003        Unknown           18.17
004        3/8/2009          86.02
```

Amazon Quick Sight 解释**Sales Date**为日期字段，并删除包含非日期值的行，因此仅导入以下行。

```
Sales ID    Sales Date    Sales Amount
--------------------------------------
001        10/14/2015        12.43
002        5/3/2012          25.00
004        3/8/2009          86.02
```

在某些情况下，数据库字段可能包含 JDBC 驱动程序无法为源数据库引擎解释的值。在这些情况下，无法解释的值将替换为 Null，以便可以导入这些行。此问题的唯一已知事例是，全部为零值的 MySQL 日期、日期时间和时间戳字段，例如 **0000-00-00 00:00:00**。例如，使用以下源数据。

```
Sales ID    Sales Date                Sales Amount
---------------------------------------------------
001        2004-10-12 09:14:27        12.43
002        2012-04-07 12:59:03        25.00
003        0000-00-00 00:00:00        18.17
004        2015-09-30 01:41:19        86.02
```

在这种情况下，将导入以下数据。

```
Sales ID    Sales Date                Sales Amount
---------------------------------------------------
001        2004-10-12 09:14:27        12.43
002        2012-04-07 12:59:03        25.00
003        (null)                     18.17
004        2015-09-30 01:41:19        86.02
```