

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# 调用 Data API
<a name="data-api-calling"></a>

您可以调用数据 API 或 Amazon CLI 以在集群或无服务器工作组上运行 SQL 语句。运行 SQL 语句的主要操作是《Amazon Redshift Data API Reference》**中的 [https://docs.amazonaws.cn/redshift-data/latest/APIReference/API_ExecuteStatement.html](https://docs.amazonaws.cn/redshift-data/latest/APIReference/API_ExecuteStatement.html) 和 [https://docs.amazonaws.cn/redshift-data/latest/APIReference/API_BatchExecuteStatement.html](https://docs.amazonaws.cn/redshift-data/latest/APIReference/API_BatchExecuteStatement.html)。数据 API 支持 Amazon 开发工具包所支持的编程语言。有关它们的更多信息，请参阅[用于在 Amazon 上构建的工具](https://www.amazonaws.cn/tools/)。

要查看调用 Data API 的代码示例，请参阅 *GitHub* 中的 [Redshift 数据 API入门](https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api#getting-started-with-redshift-data-api)。此存储库包含使用 Amazon Lambda，从 Amazon EC2、Amazon Glue Data Catalog 和 Amazon SageMaker Runtime 访问 Amazon Redshift 数据的示例。示例编程语言包括 Python、Go、Java 和 Javascript。

您可以使用 Amazon CLI 调用 Data API。

以下示例使用 Amazon CLI 调用数据 API。要运行示例，请编辑参数值以匹配您的环境。在许多示例中，会提供 `cluster-identifier` 以针对集群运行。在针对无服务器工作组运行时，需改为提供 `workgroup-name`。这些示例演示了一些数据 API 操作。有关更多信息，请参阅 *Amazon CLI 命令参考*。

以下示例中的命令已被拆分和格式化以便于阅读。并非所有示例都显示了所有参数和响应。有关完整请求语法、请求参数、响应语法和响应元素的 API 定义，请参阅 [Amazon Redshift Data API Reference](https://docs.amazonaws.cn/redshift-data/latest/APIReference/)。