

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 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/)。

# STL\$1LOAD\$1ERRORS
<a name="r_STL_LOAD_ERRORS"></a>

显示所有 Amazon Redshift 加载错误的记录。

STL\$1LOAD\$1ERRORS 包含所有 Amazon Redshift 加载错误的历史记录。有关可能的加载错误和说明的全面列表，请参阅[加载错误参考](r_Load_Error_Reference.md)。

在您查询 STL\$1LOAD\$1ERRORS 以了解有关错误的一般信息后，可查询 [STL\$1LOADERROR\$1DETAIL](r_STL_LOADERROR_DETAIL.md) 以获取其他详细信息，如发生解析错误的准确的数据行和列。

STL\$1LOAD\$1ERRORS 对所有用户可见。超级用户可以查看所有行；普通用户只能查看其自己的数据。有关更多信息，请参阅 [系统表和视图中的数据可见性](cm_chap_system-tables.md#c_visibility-of-data)。

**注意**  
STL\$1LOAD\$1ERRORS 仅包含在主预置集群上运行的查询。它不包含在并发扩展集群或无服务器命名空间上运行的查询。要访问在主集群、并发扩展集群和无服务器命名空间上运行的查询的解释计划，我们建议您使用 SYS 监控视图 [SYS\$1LOAD\$1ERROR\$1DETAIL](SYS_LOAD_ERROR_DETAIL.md)。SYS 监控视图中的数据经过格式化处理，便于使用和理解。

## 表列
<a name="r_STL_LOAD_ERRORS-table-columns2"></a>

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/redshift/latest/dg/r_STL_LOAD_ERRORS.html)

## 示例查询
<a name="r_STL_LOAD_ERRORS-sample-queries2"></a>

以下查询将 STL\$1LOAD\$1ERRORS 联接到 STL\$1LOADERROR\$1DETAIL 以查看最近加载期间发生的错误的详细信息。

```
select d.query, substring(d.filename,14,20), 
d.line_number as line, 
substring(d.value,1,16) as value,
substring(le.err_reason,1,48) as err_reason
from stl_loaderror_detail d, stl_load_errors le
where d.query = le.query
and d.query = pg_last_copy_id(); 

 query |    substring      | line |  value   |              err_reason
-------+-------------------+------+----------+----------------------------
    558| allusers_pipe.txt |  251 | 251      | String contains invalid or 
                                               unsupported UTF8 code
    558| allusers_pipe.txt |  251 | ZRU29FGR | String contains invalid or 
                                               unsupported UTF8 code
    558| allusers_pipe.txt |  251 | Kaitlin  | String contains invalid or 
                                               unsupported UTF8 code
    558| allusers_pipe.txt |  251 | Walter   | String contains invalid or 
                                               unsupported UTF8 code
```

以下示例结合使用 STL\$1LOAD\$1ERRORS 和 STV\$1TBL\$1PERM 来创建新视图，然后使用该视图来确定在将数据加载到 EVENT 表中时发生的错误：

```
create view loadview as
(select distinct tbl, trim(name) as table_name, query, starttime,
trim(filename) as input, line_number, colname, err_code,
trim(err_reason) as reason
from stl_load_errors sl, stv_tbl_perm sp
where sl.tbl = sp.id);
```

接下来，以下查询实际返回在加载 EVENT 表时发生的最后一个错误：

```
select table_name, query, line_number, colname, starttime, 
trim(reason) as error
from loadview
where table_name ='event'
order by line_number limit 1;
```

查询返回 EVENT 表发生的最后一个加载错误。如果未发生任何加载错误，则查询返回零行。在此示例中，查询返回一个错误：

```
 table_name | query | line_number | colname | error | starttime
------+-----+----+----+--------------------------------------------------------+----------------------
event | 309 |  0 |  5 | Error in Timestamp value or format [%Y-%m-%d %H:%M:%S] | 2014-04-22 15:12:44

(1 row)
```

 在 COPY 命令自动拆分大的、未压缩的、以文本分隔的文件数据以促进并行化的情况下，*line\$1number*、*is\$1partial* 和 *start\$1offset* 列显示与拆分有关的信息。（在原始文件中行号不可用的情况下，行号可能是未知的。） 

```
--scan ranges information
SELECT line_number, POSITION, btrim(raw_line), btrim(raw_field_value),
btrim(err_reason), is_partial, start_offset FROM stl_load_errors
WHERE query = pg_last_copy_id();

--result
-1,51,"1008771|13463413|463414|2|28.00|38520.72|0.06|0.07|NO|1998-08-30|1998-09-25|1998-09-04|TAKE BACK RETURN|RAIL|ans cajole sly","NO","Char length exceeds DDL length",1,67108864
```