Skip to content
Snippets Groups Projects
Unverified Commit 22ce27f1 authored by Cal Herries's avatar Cal Herries Committed by GitHub
Browse files

Remove special describe-table-fks for redshift (#39011)

parent 585891d0
No related branches found
No related tags found
No related merge requests found
......@@ -49,38 +49,6 @@
[& args]
(apply (get-method driver/describe-table :sql-jdbc) args))
;; The Postgres JDBC .getImportedKeys method doesn't work for Redshift, and we're not allowed to access
;; information_schema.constraint_column_usage, so we'll have to use this custom query instead
;;
;; See also: [Related Postgres JDBC driver issue on GitHub](https://github.com/pgjdbc/pgjdbc/issues/79)
;; [How to access the equivalent of information_schema.constraint_column_usage in Redshift](https://forums.aws.amazon.com/thread.jspa?threadID=133514)
(def ^:private fk-query
"SELECT source_column.attname AS \"fk-column-name\",
dest_table.relname AS \"dest-table-name\",
dest_table_ns.nspname AS \"dest-table-schema\",
dest_column.attname AS \"dest-column-name\"
FROM pg_constraint c
JOIN pg_namespace n ON c.connamespace = n.oid
JOIN pg_class source_table ON c.conrelid = source_table.oid
JOIN pg_attribute source_column ON c.conrelid = source_column.attrelid
JOIN pg_class dest_table ON c.confrelid = dest_table.oid
JOIN pg_namespace dest_table_ns ON dest_table.relnamespace = dest_table_ns.oid
JOIN pg_attribute dest_column ON c.confrelid = dest_column.attrelid
WHERE c.contype = 'f'::char
AND source_table.relname = ?
AND n.nspname = ?
AND source_column.attnum = ANY(c.conkey)
AND dest_column.attnum = ANY(c.confkey)")
(defmethod driver/describe-table-fks :redshift
[_ database table]
(set (for [fk (jdbc/query (sql-jdbc.conn/db->pooled-connection-spec database)
[fk-query (:name table) (:schema table)])]
{:fk-column-name (:fk-column-name fk)
:dest-table {:name (:dest-table-name fk)
:schema (:dest-table-schema fk)}
:dest-column-name (:dest-column-name fk)})))
(defmethod driver/db-start-of-week :redshift
[_]
:sunday)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment