/* 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;