                                      AND dest_column.attnum   = ANY(c.confkey)"
                              (:name table)
                              (:schema table)])]
-         {:fk-column-name (:fk-column-name fk)
-          :dest-table {:name   (:dest-table-name fk)
-                       :schema (:dest-table-schema fk)}
+         {: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)})))
 
 (defrecord RedshiftDriver []

(u/strict-extend RedshiftDriver
  driver/IDriver
  (merge (sql/IDriverSQLDefaultsMixin)
         {:date-interval       date-interval
          :describe-table-fks  describe-table-fks
          :details-fields      (constantly [{:name         "host"
                                             :display-name "Host"
                                             :placeholder  "my-cluster-name.abcd1234.us-east-1.redshift.amazonaws.com"

            [metabase.util :as u]
            [metabase.util.korma-extensions :as kx]))

(defn- connection-details->spec [details]
  (kdb/postgres (merge details postgres/ssl-params))) ; always connect to redshift over SSL

(defn- date-interval [unit amount]
  (k/raw (format "(GETDATE() + INTERVAL '%d %s')" (int amount) (name unit))))

(defn- unix-timestamp->timestamp [expr seconds-or-milliseconds]
  (case seconds-or-milliseconds
    :seconds      (kx/+ (k/raw "TIMESTAMP '1970-01-01T00:00:00Z'")
                        (kx/* expr
                              (k/raw "INTERVAL '1 second'")))
    :milliseconds (recur (kx// expr 1000) :seconds)))

;; 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)
(defn- describe-table-fks [database table]
  (set (for [fk (jdbc/query (sql/db->jdbc-connection-spec database)
                            ["SELECT source_column.attname AS \"fk-column-name\",
                                     dest_table.relname    AS \"dest-table-name\",
