hearthsim / docker-pgredshift Goto Github PK
View Code? Open in Web Editor NEWRedshift docker image based on postgres
Home Page: https://hub.docker.com/repository/docker/hearthsim/pgredshift
License: MIT License
Redshift docker image based on postgres
Home Page: https://hub.docker.com/repository/docker/hearthsim/pgredshift
License: MIT License
CREATE TABLE public.__yuniql_schema_version(
sequence_id INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
version VARCHAR(512) NOT NULL,
applied_on_utc TIMESTAMP NOT NULL DEFAULT(GETDATE()),
applied_by_user VARCHAR(128) NOT NULL DEFAULT(CURRENT_USER),
applied_by_tool VARCHAR(32) NOT NULL,
applied_by_tool_version VARCHAR(16) NOT NULL,
status VARCHAR(32) NOT NULL,
duration_ms INTEGER NOT NULL,
checksum VARCHAR(64) NOT NULL,
failed_script_path VARCHAR(4000) NULL,
failed_script_error VARCHAR(4000) NULL,
additional_artifacts VARCHAR(4000) NULL,
CONSTRAINT ix___yuniql_schema_version UNIQUE(version)
);
ERR 2021-12-30 21:32:40Z Failed to execute run function. 42601: syntax error at or near "IDENTITY"
Diagnostics stack trace captured a Npgsql.PostgresException (0x80004005):
It expects a 'dev' database in Redshift which is "postgres" in pgsql
SELECT 1 from pg_database WHERE datname = 'yuniqldb';
ERR 2021-12-30 21:35:45Z Failed to execute run function. 3D000: database "dev" does not exist
Diagnostics stack trace captured a Npgsql.PostgresException (0x80004005):
Potentially drop unsupported functions, at least the documented ones.
https://docs.aws.amazon.com/redshift/latest/dg/c_unsupported-postgresql-functions.html
https://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html
Doing so will require patching the postgres source.
Example commits and relevant code:
It would be great to have a framework that we could test created functions against expected results.
For example, testing
SELECT getdate();
would ensure that the added function would return a TIMESTAMP and its value is what we expected. These tests would be more complex when testing lots of inputs (see this PR).
I don't know if there is a framework to do this easily but I suspect it will require an additional dependency and the value of ensuring the functions work across postgres versions would be worth it.
Compare:
select json_extract_array_element_text('["Sandwich", "Omelette", "Tikka Masala"]', 0)
In Redshift, that gets you an unquoted Sandwich
, in docker-pgredshift that gets you a double-quoted "Sandwich"
.
Adding .strip('"')
to the json.dumps
seems to solve it:
CREATE FUNCTION json_extract_array_element_text(json_array text, array_index int) RETURNS text immutable as $$
import json
result = json.loads(json_array)[array_index]
return json.dumps(result).strip('"')
$$ LANGUAGE plpythonu;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.