sql Redshift兼容性功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Redshift兼容性功能相关的知识,希望对你有一定的参考价值。

/* Functions available in Redshift that can be emulated in Postgres for compatibility.
 * This is most applicable when a schema needs to be migrated into a (local) PostgreSQL
 * environment for modeling/development. As Redshift is derived from PostgreSQL, many
 * DBA and related modeling tools designed for PostgreSQL are _not quite_ viable for
 * use with Redshift. These functions attempt to augment native PostgreSQL to allow
 * Redshift SQL to run in other Postges environments.
 * I'll update this periodically with additional functions as needed.
 */

CREATE FUNCTION public.getdate() returns timestamptz
       stable language sql as 'select now()';

CREATE FUNCTION date_diff(text, timestamp, timestamp) returns integer as $$
DECLARE
  span interval := age($2, $3);
BEGIN
  select date_part($1, span);
END
$$ language plpgsql;

以上是关于sql Redshift兼容性功能的主要内容,如果未能解决你的问题,请参考以下文章

AWS Redshift 中嵌套游标的替代方案

从 Redshift 表中获取 JSON 数据

Redshift UDF boto sql 查询和 S3

昨天 - 在 Redshift 和 PostgreSQL 中 - 日期添加兼容性

Redshift SQL - 将行按 id 转换为列

如何从 SQL Server 表生成 Reshift 兼容表架构