

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

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

# Apache Iceberg 資料表支援的資料類型
<a name="querying-iceberg-supported-data-types"></a>

本主題說明 Redshift Spectrum 可從 Apache Iceberg 格式資料表讀取的支援資料類型。

Amazon Redshift 可以查詢包含下列資料類型的 Iceberg 資料表：

```
binary
boolean
date
decimal
double
float
int
list
long
map
string
struct
timestamp without time zone
```

當您建立和定義 Iceberg 資料表時，請使用 SQL 陳述式中的 Amazon Redshift 資料類型名稱。Redshift 會自動將它們映射到對應的 Iceberg 類型。如需 Iceberg 資料類型的相關資訊，請參閱 Apache Iceberg 文件中的 [Iceberg 結構描述](https://iceberg.apache.org/docs/latest/schemas/)。

從 Iceberg 資料表讀取時，Iceberg 資料類型會映射至 Redshift 資料類型，如下表所示：


****  

| Iceberg 類型 | Amazon Redshift 類型 | 備註 | 
| --- | --- | --- | 
| boolean | boolean | - | 
| - | tinyint | Iceberg 資料表不支援。 | 
| - | smallint | Iceberg 資料表不支援。 | 
| int | int | - | 
| long | bigint | - | 
| double | double precision | - | 
| float | real | - | 
| decimal(P, S) | decimal(P, S) | P 是總位數，S 是小數部分的位數。 | 
| - | char | Iceberg 資料表不支援。 | 
| string | varchar(16384) | 大於 16384 的字串會截斷至 16384。 | 
| binary | varbyte(64000) | - | 
| date | date | - | 
| time | - | - | 
| timestamp | timestamp | - | 
| timestamptz | timestampz | - | 
| list<E> | SUPER | - | 
| map<K,V> | SUPER | - | 
| struct<...> | SUPER | - | 
| fixed(L) | - | Redshift Spectrum 目前不支援 fixed(L) 類型。 | 
| uuid | - | Redshift Spectrum 目前不支援 uuid 類型。 | 
| variant | - | Amazon Redshift 不支援 Iceberg V3。 | 
| geometry | - | Amazon Redshift 不支援 Iceberg V3。 | 
| geography | - | Amazon Redshift 不支援 Iceberg V3。 | 
| timestamp\$1ns | - | Amazon Redshift 不支援 Iceberg V3。 | 
| timestamptz\$1ns | - | Amazon Redshift 不支援 Iceberg V3。 | 
| Unknown | - | Amazon Redshift 不支援 Iceberg V3。 | 

從 Redshift 建立 Iceberg 資料表時，支援下列資料類型。Redshift 資料類型會映射至 Iceberg 資料類型，如下表所示。


****  

| Amazon Redshift 類型 | Amazon Redshift 別名 | Iceberg 類型 | 備註 | 
| --- | --- | --- | --- | 
| integer | int, int4 | int | - | 
| bigint | int8 | long | - | 
| decimal | numeric | decimal(p,S) | - | 
| real | float4 | float | - | 
| double precision | float8, float | double | - | 
| varchar | charactter varying,nvarchar, text | string | 建立 Iceberg 資料表時不支援 varchar(n)資料類型。 | 
| date | - | date | - | 
| timestamp | - | timestamp | - | 
| timestamptz | - | timestamptz | - | 
| boolean | - | boolean | - | 

寫入 Iceberg 資料表時，除了上表中提及的資料類型之外，某些來源資料類型也會提升為相容的 Iceberg 類型，如下表所示。


| Amazon Redshift 類型 | Iceberg 類型 | 
| --- | --- | 
|  `tinyint`  |  `int`  | 
|  `smallint`  |  `int`  | 
|  `varchar(n)`  |  `string`  | 

嘗試使用不支援的資料類型會導致語法錯誤。當您使用 `CREATE TABLE AS SELECT`子句建立 Iceberg 資料表時，您可以新增明確轉換來解決類型差異。

例如，假設您有一個具有下列結構描述的 Redshift RMS 資料表：

```
CREATE TABLE rms_t (c1 int, c2 char(20));
```

如果您想要使用 `rms_t`作為來源建立 Iceberg 資料表，則需要資料`c2`欄的明確轉換，因為不支援 `varchar(n)`類型：

```
CREATE TABLE ext_schema.iceberg_t AS SELECT c1, c2::varchar FROM rms_t;
```

如需 Amazon Redshift 中資料類型的相關資訊，請參閱[資料類型](c_Supported_data_types.md)。