

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 支援的資料類型和值
<a name="supported-data-types-and-values"></a>

Amazon Quick Sight 目前支援下列基本資料類型：`Date`、`Integer`、 `Decimal`和 `String`。SPICE 中支援下列資料類型：`Date`、`Decimal-fixed`、`Decimal-float`、`Integer` 和 `String`。Quick Sight 透過將布林值提升為整數來接受布林值。它也可以推導出地理空間資料類型。地理空間資料類型使用中繼資料來解譯實體資料類型。緯度和經度為數字。所有其他地理空間類別為字串。

請確保用作資料來源的任何資料表或檔案，僅包含可隱含轉換為這些資料類型的欄位。Amazon Quick Sight 會略過任何無法轉換的欄位或資料欄。如果收到「欄位因為使用不受支援的資料類型而被略過」的錯誤訊息，請變更您的查詢或資料表，以移除或重新轉換不受支援的資料類型。

## 字串與文字資料
<a name="strings"></a>

包含字元的欄位或資料欄稱為*字串*。具有 `STRING` 資料類型的欄位一開始可以包含幾乎任何類型的資料。範例包括名稱、描述、電話號碼、帳戶號碼、JSON 資料、城市、郵遞區號、日期以及可用於計算的數字。這些類型有時在一般意義上被稱為文字資料，但在技術意義上並非如此。Quick Sight 不支援資料集欄中的二進位和字元大型物件 (BLOBs)。在 Quick Sight 文件中，「文字」一詞一律表示「字串資料」。

第一次查詢或匯入資料時，Quick Sight 會嘗試解譯其識別為其他類型的資料，例如日期和數字。驗證指派給欄位或資料欄的資料類型是否正確是很好的做法。

對於匯入資料中的每個字串欄位，Quick Sight 會使用 8 個位元組的欄位長度加上 UTF-8 編碼字元長度。Amazon Quick Sight 支援 UTF-8 檔案編碼，但不支援 UTF-8 （使用 BOM)。

## 日期和時間資料
<a name="dates"></a>

資料類型為 `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)。

## 數值資料
<a name="numeric"></a>

數字資料包括整數和小數。資料類型為 `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` 資料類型，選擇**更新欄位**。如果您不想加入，請選擇**不更新欄位**。每次您開啟**編輯資料集**頁面時，**更新欄位**都會出現，直到資料集儲存並發布。

## 來自外部資料來源的受支援資料類型
<a name="supported-data-types"></a>

下表列出搭配 Amazon Quick Sight 使用下列資料來源時支援的資料類型。


****  

| 資料庫引擎或來源 | 數值資料類型 | 字串資料類型 | 日期時間資料類型 | 布林值資料類型 | 
| --- | --- | --- | --- | --- | 
|   **Amazon Athena、Presto、Starburst、Trino**  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  | 
|  **Amazon Aurora**、**MariaDB** 和 **MySQL**  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  | 
|   **Amazon OpenSearch Service**  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  | 
|  **Oracle**  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html) | bit | 
|   **PostgreSQL**   |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  | 
|   **Apache Spark**  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  | 
|   **Snowflake**   |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  | 
|   **Microsoft SQL Server**   |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  | 

### 支援的日期格式
<a name="supported-date-formats"></a>

Amazon Quick Sight 支援本節所述的日期和時間格式。將資料新增至 Amazon Quick Sight 之前，請檢查您的日期格式是否相容。如果需要使用不受支援的格式，請參閱 [使用不支援的日期或自訂日期](using-unsupported-dates.md)。

根據資料來源類型不同，支援的格式也不同，如下所示：


| 資料來源 | 時鐘 | 日期格式 | 
| --- | --- | --- | 
|  檔案上傳 Amazon S3 來源 Athena Salesforce  |  24 小時和 12 小時制  |  Joda API 文檔中描述了受支援的日期和時間格式。 如需 Joda 日期格式的完整清單，請參閱 Joda 網站上的 [Class DateTimeFormat](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.aws.amazon.com/zh_tw/quick/latest/userguide/supported-data-types-and-values.html)  | 

### 資料中不支援的值
<a name="unsupported-data-values"></a>

如果欄位包含的值不符合 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 date、datetime 和 timestamp 欄位，例如 **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
```