-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support JDBC explicitPrepare flag
- Loading branch information
Showing
12 changed files
with
189 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"trino": "426", | ||
"trino": "431", | ||
"clojure": "1.11.1.1262", | ||
"metabase": "v1.47.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
drivers/starburst/src/metabase/driver/implementation/messages.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
;; | ||
;; Licensed under the Apache License, Version 2.0 (the "License"); | ||
;; you may not use this file except in compliance with the License. | ||
;; You may obtain a copy of the License at | ||
|
||
;; http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
;; Unless required by applicable law or agreed to in writing, software | ||
;; distributed under the License is distributed on an "AS IS" BASIS, | ||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
;; See the License for the specific language governing permissions and | ||
;; limitations under the License. | ||
;; | ||
(ns metabase.driver.implementation.messages "Starburst messages") | ||
|
||
(def STARBURST_INCOMPATIBLE_WITH_OPTIMIZED_PREPARED "\"Optimized prepared statements\" require Starburst Galaxy, Starburst Enterprise (version 420-e or higher), or Trino (version 418 or higher)") | ||
(def STARBURST_MAYBE_INCOMPATIBLE ". If the database has the \"Optimized prepared statements\" option on, it require Starburst Galaxy, Starburst Enterprise (version 420-e or higher), or Trino (version 418 or higher)") | ||
(def TOO_MANY_PARAMETERS "It looks like we got more parameters than we can handle, remember that parameters cannot be used in comments or as identifiers.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,57 @@ | |
(is (= (str "impersonate:true") | ||
(:clientInfo jdbc-spec)))))) | ||
|
||
(defn prepared-statements-helper | ||
[prepared-optimized] | ||
(is (= [["2023-11-06T00:00:00Z" 42 "It was created"]] | ||
(mt/rows | ||
(let [details { | ||
:host "localhost" | ||
:port 8082 | ||
:catalog "catalog" | ||
:user "admin" | ||
:ssl false | ||
:prepared-optimized prepared-optimized}] | ||
(t2.with-temp/with-temp [Database db {:engine :starburst, :name "Temp Trino JDBC Schema DB", :details details}] | ||
(mt/with-db db | ||
(qp/process-query | ||
{:database (mt/id) | ||
:type :native | ||
:native { | ||
:query "SELECT {{created_at}}, {{nb_created}}, {{detail}}" | ||
:template-tags {:created_at {:name "created_at" | ||
:display_name "created_at" | ||
:type :date | ||
:required true} | ||
:nb_created {:name "nb_created" | ||
:display_name "nb_created" | ||
:type :number | ||
:required true} | ||
:detail {:name "detail" | ||
:display_name "detail" | ||
:type :text | ||
:required true}}} | ||
:parameters [{:type :date | ||
:name "created_at" | ||
:target [:variable [:template-tag "created_at"]] | ||
:value "2023-11-06"} | ||
{:type :number | ||
:name "nb_created" | ||
:target [:variable [:template-tag "nb_created"]] | ||
:value "42"} | ||
{:type :text | ||
:name "detail" | ||
:target [:variable [:template-tag "detail"]] | ||
:value "It was created"}]})))))))) | ||
|
||
(deftest prepared-statements | ||
(mt/test-driver :starburst | ||
(testing "Make sure prepared statements work" | ||
;; If impersonation is set, then the Trino user should be the current Metabase user, i.e. [email protected] | ||
;; The role is ignored as Metabase users may not have the role defined in the database connection | ||
(prepared-statements-helper true) | ||
(prepared-statements-helper false)))) | ||
|
||
(deftest impersonation-query | ||
(mt/test-driver :starburst | ||
(testing "Make sure the right credentials are used depending on the impersonation checkbox" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters