Skip to content

Commit

Permalink
fix query building
Browse files Browse the repository at this point in the history
  • Loading branch information
stepansergeevitch committed Sep 11, 2024
1 parent b0bb14a commit 4f40615
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/metabase/driver/firebolt.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/(ns metabase.driver.firebolt
(ns metabase.driver.firebolt
(:require [clojure
[string :as str]
[set :as set]]
[clojure.java.jdbc :as jdbc]
[java-time.api :as t]
[metabase.driver :as driver]
[metabase.driver.common :as driver.common]
[metabase.driver.sql-jdbc.sync.describe-table :as sql-jdbc.describe-table]
[metabase.driver.sql-jdbc
[common :as sql-jdbc.common]
[connection :as sql-jdbc.conn]
Expand Down Expand Up @@ -229,20 +230,20 @@
(set(for [{:keys [database table_name]} (jdbc/query {:connection conn} ["SELECT table_name from information_schema.views WHERE table_schema LIKE 'public'"])]
{:name table_name :schema (when (seq database) database)}))))})

(defmethod driver/get-table-pks :firebolt
(defmethod sql-jdbc.describe-table/get-table-pks :firebolt
[_ ^Connection conn db-name-or-nil table]
(let [table-name (get table :name)
schema (get table :schema)
sql-query (if (nil? db-name-or-nil)
(str "SELECT primary-index FROM information_schema.tables WHERE table_name = ? AND table_schema = ?")
(str "SELECT primary-index FROM information_schema.tables WHERE table_name = ? AND table_schema = ? AND table_catalog = ?")
)
"SELECT primary-index FROM information_schema.tables WHERE table_name = ?"
"SELECT primary-index FROM information_schema.tables WHERE table_name = ? AND table_catalog = ?"
)
sql-params (if (nil? db-name-or-nil)
[table-name schema]
[table-name schema db-name-or-nil]
[table-name]
[table-name db-name-or-nil]
)
pk-result (jdbc/query {:connection conn}
concat ([sql-query] sql-params))
(concat [sql-query] sql-params))
]
(->> pk-result
first ;; get the first row
Expand Down

0 comments on commit 4f40615

Please sign in to comment.