The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Add missing honeysql util methods for mbql5 drivers (#75024)
Riley Thompson33beb183c295
diff --git a/src/metabase/driver/h2.clj b/src/metabase/driver/h2.cljindex 683b5e8fee2..06520afc994 100644--- a/src/metabase/driver/h2.clj+++ b/src/metabase/driver/h2.clj@@ -331,6 +331,10 @@[driver hsql-form amount unit](h2x/add-interval-honeysql-form driver hsql-form amount unit))+(defmethod sql.qp/add-interval-honeysql-form :h2-mbql5+ [driver hsql-form amount unit]+ (h2x/add-interval-honeysql-form driver hsql-form amount unit))+(defmethod driver/humanize-connection-error-message :h2[_ messages](let [message (first messages)]@@ -360,6 +364,10 @@[driver](h2x/current-datetime-honeysql-form driver))+(defmethod sql.qp/current-datetime-honeysql-form :h2-mbql5+ [driver]+ (h2x/current-datetime-honeysql-form driver))+(defn- add-to-1970 [expr unit-str][:timestampadd(h2x/literal unit-str)diff --git a/src/metabase/driver/postgres.clj b/src/metabase/driver/postgres.cljindex 4e56f291392..cee74c19aea 100644--- a/src/metabase/driver/postgres.clj+++ b/src/metabase/driver/postgres.clj@@ -494,10 +494,18 @@[driver hsql-form amount unit](h2x/add-interval-honeysql-form driver hsql-form amount unit))+(defmethod sql.qp/add-interval-honeysql-form :postgres-mbql5+ [driver hsql-form amount unit]+ (h2x/add-interval-honeysql-form driver hsql-form amount unit))+(defmethod sql.qp/current-datetime-honeysql-form :postgres[driver](h2x/current-datetime-honeysql-form driver))+(defmethod sql.qp/current-datetime-honeysql-form :postgres-mbql5+ [driver]+ (h2x/current-datetime-honeysql-form driver))+(defmethod sql.qp/unix-timestamp->honeysql [:postgres :seconds][_ _ expr];; without tagging the expression, other code will want to add a typediff --git a/src/metabase/sql_tools/sqlglot/core.clj b/src/metabase/sql_tools/sqlglot/core.cljindex 364514382e6..c48ff2dc6a7 100644--- a/src/metabase/sql_tools/sqlglot/core.clj+++ b/src/metabase/sql_tools/sqlglot/core.clj@@ -34,6 +34,7 @@(case drivernil nil:postgres "postgres"+ :postgres-mbql5 "postgres":mysql "mysql":snowflake "snowflake":bigquery "bigquery"diff --git a/src/metabase/util/honey_sql_2.clj b/src/metabase/util/honey_sql_2.cljindex 461f2b2a9b3..92acd45437a 100644--- a/src/metabase/util/honey_sql_2.clj+++ b/src/metabase/util/honey_sql_2.clj@@ -438,7 +438,7 @@(case db-type(:h2 :h2-mbql5) (with-database-type-info :%now "timestamp"):mysql (with-database-type-info [:now [:inline 6]] "timestamp")- :postgres (with-database-type-info :%now "timestamptz")))+ (:postgres :postgres-mbql5) (with-database-type-info :%now "timestamptz")))(defn- format-postgres-interval"Generate a Postgres 'INTERVAL' literal.@@ -493,6 +493,10 @@(-> (+ hsql-form (pg-interval amount unit))(with-type-info (type-info hsql-form))))))+(defmethod add-interval-honeysql-form :postgres-mbql5+ [db-type hsql-form amount unit]+ ((get-method add-interval-honeysql-form :postgres) db-type hsql-form amount unit))+(defmethod add-interval-honeysql-form :mysql[db-type hsql-form amount unit];; MySQL doesn't support `:millisecond` as an option, but does support fractional seconds