Skip to content
Snippets Groups Projects
Unverified Commit 2066338a authored by flamber's avatar flamber Committed by GitHub
Browse files

Adjust expressions and driver supported features (#12675)

parent 3378bf3a
Branches
Tags
No related merge requests found
......@@ -86,12 +86,14 @@ After you click on the Join Data button to add a join step, you'll need to pick
Next, you'll need to pick the columns you want to join on. This means you pick a column from the first table, and a column from the second table, and the join will stitch rows together where the value from the first column is equal to the value in the second column. A very common example is to join on an ID column in each table, so if you happened to pick a table to join on where there is a foreign key relationship between the tables, Metabase will automatically pick those corresponding ID columns for you. At the end of your join step, there's a `Columns` button you can click to choose which columns you want to include from the joined data.
By default, Metabase will do a left outer join, but you can click on the Venn diagram icon to change this to a different type of join. The options you'll see will differ based on the type of database you're using. Here are what the basic types of joins each do:
By default, Metabase will do a left outer join, but you can click on the Venn diagram icon to select a different type of join. Not all databases support all types of joins, so Metabase will only display the options supported by the database you're using.
Here are the basic types of joins:
- **Left outer join:** select all records from Table A, along with records from Table B that meet the join condition, if any.
- **Right outer join:** select all records from Table B, along with records from Table B that meet the join condition, if any.
- **Right outer join:** select all records from Table B, along with records from Table A that meet the join condition, if any.
- **Inner join:** only select the records from Table A and B where the join condition is met.
- **Full outer join:** select all records from both tables, whether or not the join condition is met. This is not available for MySQL or H2, and is only available for some database types, like Spark SQL, SQL Server, and SQLite.
- **Full outer join:** select all records from both tables, whether or not the join condition is met.
**A left outer join example:** If Table A is Orders and Table B is Customers, and assuming you do a join where the `customer_id` column in Orders is equal to the `ID` column in Customers, when you do a left outer join your results will be a full list of all your orders, and each order row will also display the columns of the customer who placed that order. Since a single customer can place many orders, a given customer's information might be repeated many times for different order rows. If there isn't a corresponding customer for a given order, the order's information will be shown, but the customer columns will just be blank for that row.
......
......@@ -94,21 +94,18 @@ This would return rows where `Created At` is between January 1, 2020 and March 3
Certain database types don't support some of the above functions:
MySQL and SQL Server
**BigQuery**: `abs`, `ceil`, `floor`, `median`, `percentile` and `round`
- median
- percentile
**H2**: `median`, `percentile` and `regexextract`
SQLite
**MySQL**: `median`, `percentile` and `regexextract`
- log
- median
- percentile
- power
- standardDeviation
- sqrt
- variance
**SQL Server**: `median`, `percentile` and `regexextract`
Additionally, **Vertica**, **BigQuery**, and **Presto** only provide _approximate_ results for median and percentile.
**SQLite**: `log`, `median`, `percentile`, `power`, `regexextract`, `standardDeviation`, `sqrt` and `variance`
**Vertica**: `median` and `percentile`
Additionally, **Presto** only provides _approximate_ results for `median` and `percentile`.
If you're using or maintaining a third-party database driver, please [refer to the wiki](https://github.com/metabase/metabase/wiki/What's-new-in-0.35.0-for-Metabase-driver-authors) to see how your driver might be impacted.
......@@ -27,9 +27,22 @@
(driver/register! :sqlite, :parent :sql-jdbc)
(defmethod driver/supports? [:sqlite :regex] [_ _] false)
(defmethod driver/supports? [:sqlite :percentile-aggregations] [_ _] false)
(defmethod driver/supports? [:sqlite :advanced-math-expressions] [_ _] false)
;; SQLite does not support a lot of features, so do not show the options in the interface
(doseq [[feature supported?] {:right-join false
:full-join false
:regex false
:percentile-aggregations false
:advanced-math-expressions false
:standard-deviation-aggregations false}]
(defmethod driver/supports? [:sqlite feature] [_ _] supported?))
;; SQLite `LIKE` clauses are case-insensitive by default, and thus cannot be made case-sensitive. So let people know
;; we have this 'feature' so the frontend doesn't try to present the option to you.
(defmethod driver/supports? [:sqlite :case-sensitivity-string-filter-options] [_ _] false)
;; HACK SQLite doesn't support ALTER TABLE ADD CONSTRAINT FOREIGN KEY and I don't have all day to work around this so
;; for now we'll just skip the foreign key stuff in the tests.
(defmethod driver/supports? [:sqlite :foreign-keys] [_ _] (not config/is-test?))
(defmethod sql-jdbc.conn/connection-details->spec :sqlite
[_ {:keys [db]
......@@ -280,17 +293,6 @@
(sql.qp/->honeysql driver (t/local-date t))
(hsql/call :datetime (hx/literal (u.date/format-sql t)))))
;; SQLite `LIKE` clauses are case-insensitive by default, and thus cannot be made case-sensitive. So let people know
;; we have this 'feature' so the frontend doesn't try to present the option to you.
(defmethod driver/supports? [:sqlite :case-sensitivity-string-filter-options] [_ _] false)
;; SQLite doesn't have a standard deviation function
(defmethod driver/supports? [:sqlite :standard-deviation-aggregations] [_ _] false)
;; HACK SQLite doesn't support ALTER TABLE ADD CONSTRAINT FOREIGN KEY and I don't have all day to work around this so
;; for now we'll just skip the foreign key stuff in the tests.
(defmethod driver/supports? [:sqlite :foreign-keys] [_ _] (not config/is-test?))
;; SQLite defaults everything to UTC
(defmethod driver.common/current-db-time-date-formatters :sqlite
[_]
......
......@@ -25,6 +25,10 @@
(defmethod driver/supports? [:sqlserver :regex] [_ _] false)
(defmethod driver/supports? [:sqlserver :percentile-aggregations] [_ _] false)
;; SQLServer LIKE clauses are case-sensitive or not based on whether the collation of the server and the columns
;; 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
(defmethod driver/supports? [:sqlserver :case-sensitivity-string-filter-options] [_ _] false)
;; See the list here: https://docs.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types
(defmethod sql-jdbc.sync/database-type->base-type :sqlserver
......@@ -276,11 +280,6 @@
(defmethod sql.qp/current-datetime-honeysql-form :sqlserver [_] :%getdate)
;; SQLServer LIKE clauses are case-sensitive or not based on whether the collation of the server and the columns
;; 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
(defmethod driver/supports? [:sqlserver :case-sensitivity-string-filter-options] [_ _] false)
(defmethod sql-jdbc.sync/excluded-schemas :sqlserver
[_]
#{"sys" "INFORMATION_SCHEMA"})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment