Skip to content

Commit

Permalink
rename feature to index-info
Browse files Browse the repository at this point in the history
  • Loading branch information
qnkhuat committed Dec 11, 2023
1 parent 9b9292d commit 07847b5
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/developers-guide/driver-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Driver interface changelog
# Driver Interface Changelog

## Metabase 0.49.0
- A new driver method has been added [[driver/describe-table-indexes]] along with a new feature `:indexing`.
- A new driver method has been added [[driver/describe-table-indexes]] along with a new feature `:index-info`.
This method is used to get a set of column names that are indexed or are the first columns in a composite index.

## Metabase 0.48.0
Expand Down
4 changes: 2 additions & 2 deletions src/metabase/driver.clj
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@
;; Does the driver require specifying a collection (table) for native queries? (mongo)
:native-requires-specified-collection

;; Does the driver support column(s) indexing
:indexing})
;; Does the driver support column(s) support storing index info
:index-info})


(defmulti supports?
Expand Down
2 changes: 1 addition & 1 deletion src/metabase/driver/h2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
:now true
:test/jvm-timezone-setting false
:uploads true
:indexing true}]
:index-info true}]
(defmethod driver/database-supports? [:h2 feature]
[_driver _feature _database]
supported?))
Expand Down
2 changes: 1 addition & 1 deletion src/metabase/driver/mysql.clj
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
;; themselves. Since this isn't something we can really change in the query itself don't present the option to the
;; users in the UI
:case-sensitivity-string-filter-options false
:indexing true}]
:index-info true}]
(defmethod driver/database-supports? [:mysql feature] [_driver _feature _db] supported?))

;; This is a bit of a lie since the JSON type was introduced for MySQL since 5.7.8.
Expand Down
2 changes: 1 addition & 1 deletion src/metabase/driver/postgres.clj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
:actions/custom
:table-privileges
:uploads
:indexing]]
:index-info]]
(defmethod driver/database-supports? [:postgres feature]
[driver _feat _db]
(= driver :postgres)))
Expand Down
4 changes: 2 additions & 2 deletions src/metabase/sync/sync_metadata/indexes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(defn maybe-sync-indexes-for-table!
"Sync the indexes for `table` if the driver supports indexing."
[database table]
(if (driver/database-supports? (driver.u/database->driver database) :indexing database)
(if (driver/database-supports? (driver.u/database->driver database) :index-info database)
(sync-util/with-error-handling (format "Error syncing Indexes for %s" (sync-util/name-for-logging table))
(let [indexes (fetch-metadata/index-metadata database table)
;; not all indexes are field names, they could be function based index as well
Expand All @@ -42,7 +42,7 @@
(defn maybe-sync-indexes!
"Sync the indexes for all tables in `database` if the driver supports indexing."
[database]
(if (driver/database-supports? (driver.u/database->driver database) :indexing database)
(if (driver/database-supports? (driver.u/database->driver database) :index-info database)
(apply merge-with + empty-stats
(map #(maybe-sync-indexes-for-table! database %) (sync-util/db->sync-tables database)))
empty-stats))
4 changes: 2 additions & 2 deletions test/metabase/driver/sql_jdbc/sync/describe_table_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
(t2/select-one Table :db_id (mt/id) :name "json_without_pk"))))))))))))

(deftest describe-table-indexes-test
(mt/test-drivers (mt/normal-drivers-with-feature :indexing)
(mt/test-drivers (mt/normal-drivers-with-feature :index-info)
(mt/dataset (mt/dataset-definition "indexes"
["single_index"
[{:field-name "indexed" :indexed? true :base-type :type/Integer}
Expand Down Expand Up @@ -502,7 +502,7 @@

(deftest describe-table-indexes-advanced-index-type-test
;; a set of tests for advanced index types
(mt/test-drivers (mt/normal-drivers-with-feature :indexing)
(mt/test-drivers (mt/normal-drivers-with-feature :index-info)
(mt/dataset (mt/dataset-definition "advanced-indexes"
["unique_index"
[{:field-name "column" :indexed? false :base-type :type/Integer}]
Expand Down
4 changes: 2 additions & 2 deletions test/metabase/sync/sync_metadata/indexes_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[toucan2.core :as t2]))

(deftest sync-single-indexed-columns-test
(mt/test-drivers (mt/normal-drivers-with-feature :indexing)
(mt/test-drivers (mt/normal-drivers-with-feature :index-info)
(mt/dataset (mt/dataset-definition "single_index"
["table"
[{:field-name "indexed" :indexed? true :base-type :type/Integer}
Expand All @@ -21,7 +21,7 @@
(is (false? (t2/select-one-fn :database_indexed :model/Field (mt/id :table :not-indexed)))))))

(deftest sync-composite-indexed-columns-test
(mt/test-drivers (mt/normal-drivers-with-feature :indexing)
(mt/test-drivers (mt/normal-drivers-with-feature :index-info)
(mt/dataset (mt/dataset-definition "composite-index"
["table"
[{:field-name "first" :indexed? false :base-type :type/Integer}
Expand Down

0 comments on commit 07847b5

Please sign in to comment.