Skip to content

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

Fix: Redshift external tables have unknown types for string/enum columns on sync (#67028)

github-actions[bot]1c5150508be5
diff --git a/modules/drivers/redshift/src/metabase/driver/redshift.clj b/modules/drivers/redshift/src/metabase/driver/redshift.clj
index 0c13f1f5b5e..a4e8a143e6d 100644
--- a/modules/drivers/redshift/src/metabase/driver/redshift.clj
+++ b/modules/drivers/redshift/src/metabase/driver/redshift.clj
@@ -224,6 +224,19 @@
(str/starts-with? stn "mediumtext") :type/Text
(str/starts-with? stn "longtext") :type/Text
+ ;; Iceberg table types - https://docs.aws.amazon.com/redshift/latest/dg/querying-iceberg-supported-data-types.html
+ (= stn "string") :type/Text
+ (= stn "boolean") :type/Boolean
+ (= stn "long") :type/BigInteger
+ (str/starts-with? stn "decimal(") :type/Decimal
+ (= stn "binary") :type/*
+ (= stn "date") :type/Date
+ (= stn "timestamp") :type/DateTime
+ (= stn "timestamptz") :type/DateTimeWithTZ
+
+ ;; MySQL federated table enum types
+ (str/starts-with? stn "enum(") :type/Text
+
(= stn "datetime") :type/DateTime
(= stn "year") :type/Integer))))
diff --git a/modules/drivers/redshift/test/metabase/driver/redshift_test.clj b/modules/drivers/redshift/test/metabase/driver/redshift_test.clj
index fb565ac8e4d..a6e2d978a08 100644
--- a/modules/drivers/redshift/test/metabase/driver/redshift_test.clj
+++ b/modules/drivers/redshift/test/metabase/driver/redshift_test.clj
@@ -514,6 +514,25 @@
["float(10)" :type/Float]
["datetime" :type/DateTime]
["year" :type/Integer]
+ ;; Iceberg table types https://docs.aws.amazon.com/redshift/latest/dg/querying-iceberg-supported-data-types.html
+ ["string" :type/Text]
+ [:string :type/Text]
+ [:STRING :type/Text]
+ ["boolean" :type/Boolean]
+ ["int" :type/Integer]
+ ["long" :type/BigInteger]
+ ["double" :type/Float]
+ ["decimal(2, 10)" :type/Decimal]
+ ["binary" :type/*]
+ ["date" :type/Date]
+ ["time" nil]
+ ["timestamp" :type/DateTime]
+ ["timestamptz" :type/DateTimeWithTZ]
+
+ ;; MySQL federated table enum types
+ ["enum('A','B')" :type/Text]
+ ["enum('open','closed')" :type/Text]
+ ["enum('active','inactive')" :type/Text]
;; nonsense
["fadlsjfldskajfl" nil]]]
(testing (format "database-type %s" (pr-str database-type))