Skip to content

Commit

Permalink
Disable :left-join for now, impl tx/dataset-already-loaded?override
Browse files Browse the repository at this point in the history
  • Loading branch information
slvrtrn committed Oct 25, 2024
1 parent 8e05cfa commit 69bdb72
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
pull_request:

env:
METABASE_VERSION: v0.50.30.1
METABASE_VERSION: v1.51.1.2

jobs:
check-local-current-version:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ services:
##########################################################################################################

metabase:
image: metabase/metabase-enterprise:v1.50.3
image: metabase/metabase-enterprise:v1.51.1.2
container_name: metabase-with-clickhouse-driver
hostname: metabase
environment:
Expand Down
3 changes: 2 additions & 1 deletion src/metabase/driver/clickhouse.clj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
:schemas true
:datetime-diff true
:upload-with-auto-pk false
:window-functions/offset false}]
:window-functions/offset false
:left-join false}]
(defmethod driver/database-supports? [:clickhouse feature] [_driver _feature _db] supported?))

(def ^:private default-connection-details
Expand Down
23 changes: 21 additions & 2 deletions test/metabase/test/data/clickhouse.clj
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
[f]
(when (not @test-db-initialized?)
(let [details (tx/dbdef->connection-details :clickhouse :db {:database-name "metabase_test"})]
(println "Executing create-test-db! with details:" details)
;; (println "Executing create-test-db! with details:" details)
(jdbc/with-db-connection
[spec (sql-jdbc.conn/connection-details->spec :clickhouse (merge {:engine :clickhouse} details))]
(let [statements (as-> (slurp "modules/drivers/clickhouse/test/metabase/test/data/datasets.sql") s
Expand All @@ -167,7 +167,7 @@
{:write? true}
(fn [^java.sql.Connection conn]
(doseq [statement statements]
(println "Executing:" statement)
;; (println "Executing:" statement)
(with-open [jdbcStmt (.createStatement conn)]
(let [^ClickHouseStatementImpl clickhouseStmt (.unwrap jdbcStmt ClickHouseStatementImpl)
request (.getRequest clickhouseStmt)]
Expand All @@ -186,3 +186,22 @@
:details (tx/dbdef->connection-details :clickhouse :db {:database-name "metabase_test"})}]
(sync-metadata/sync-db-metadata! database)
(f database)))

(defmethod tx/dataset-already-loaded? :clickhouse
[driver dbdef]
(let [tabledef (first (:table-definitions dbdef))
db-name (ddl.i/format-name :clickhouse (:database-name dbdef))
table-name (ddl.i/format-name :clickhouse (:table-name tabledef))
details (tx/dbdef->connection-details :clickhouse :db {:database-name db-name})]
(sql-jdbc.execute/do-with-connection-with-options
driver
(sql-jdbc.conn/connection-details->spec driver details)
{:write? false}
(fn [^java.sql.Connection conn]
(with-open [rset (.getTables (.getMetaData conn)
#_catalog nil
#_schema-pattern db-name
#_table-pattern table-name
#_types (into-array String ["TABLE"]))]
;; if the ResultSet returns anything we know the table is already loaded.
(.next rset))))))

0 comments on commit 69bdb72

Please sign in to comment.