Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Sync field descriptions for Postgres materialized views (#84059)

Riley Thompson63346fa81622
diff --git a/src/metabase/driver/postgres.clj b/src/metabase/driver/postgres.clj
index 7bfcea3175d..722128fd899 100644
--- a/src/metabase/driver/postgres.clj
+++ b/src/metabase/driver/postgres.clj
@@ -405,7 +405,7 @@
[:pn.nspname :table-schema]
[:pc.relname :table-name]
[false :pk?]
- [nil :field-comment]
+ [[:col_description :pc.oid :pa.attnum] :field-comment]
[false :database-required]
[nil :database-default]
[false :database-is-auto-increment]
diff --git a/test/metabase/driver/postgres_test.clj b/test/metabase/driver/postgres_test.clj
index c09af2dfccc..2ff9e924a99 100644
--- a/test/metabase/driver/postgres_test.clj
+++ b/test/metabase/driver/postgres_test.clj
@@ -300,10 +300,16 @@
["DROP MATERIALIZED VIEW IF EXISTS test_mview;
CREATE MATERIALIZED VIEW test_mview AS
SELECT 'Toucans are the coolest type of bird.' AS true_facts;
+ COMMENT ON COLUMN test_mview.true_facts IS 'Facts that are true';
ANALYZE test_mview;"])
(mt/with-temp [:model/Database database {:engine :postgres, :details (assoc details :dbname "materialized_views_test")}]
(is (=? [(default-table-result "test_mview")]
- (describe-database->tables :postgres database))))))))
+ (describe-database->tables :postgres database)))
+ (is (=? [{:table-schema "public"
+ :table-name "test_mview"
+ :name "true_facts"
+ :field-comment "Facts that are true"}]
+ (into [] (driver/describe-fields :postgres database {:table-names ["test_mview"]})))))))))
(deftest foreign-tables-test
(mt/test-driver :postgres