Skip to content

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

Add new columns to metabase_field for internal-tools/data-apps (#60263)

Dan Stoneec16936ff89c
diff --git a/modules/drivers/bigquery-cloud-sdk/test/metabase/test/data/bigquery_cloud_sdk.clj b/modules/drivers/bigquery-cloud-sdk/test/metabase/test/data/bigquery_cloud_sdk.clj
index 354a304ea7d..07fa68c9324 100644
--- a/modules/drivers/bigquery-cloud-sdk/test/metabase/test/data/bigquery_cloud_sdk.clj
+++ b/modules/drivers/bigquery-cloud-sdk/test/metabase/test/data/bigquery_cloud_sdk.clj
@@ -322,18 +322,19 @@
(defn- load-tabledef! [dataset-id {:keys [table-name field-definitions], :as tabledef}]
(let [table-name (normalize-name table-name)]
(create-table! dataset-id table-name field-definitions)
- ;; retry the `insert-data!` step up to 5 times because it seens to fail silently a lot. Since each row is given a
- ;; unique key it shouldn't result in duplicates.
- (loop [num-retries 5]
- (let [^Throwable e (try
- (insert-data! dataset-id table-name (tabledef->prepared-rows tabledef))
- nil
- (catch Throwable e
- e))]
- (when e
- (if (pos? num-retries)
- (recur (dec num-retries))
- (throw e)))))))
+ (when (seq (:rows tabledef))
+ ;; retry the `insert-data!` step up to 5 times because it seens to fail silently a lot. Since each row is given a
+ ;; unique key it shouldn't result in duplicates.
+ (loop [num-retries 5]
+ (let [^Throwable e (try
+ (insert-data! dataset-id table-name (tabledef->prepared-rows tabledef))
+ nil
+ (catch Throwable e
+ e))]
+ (when e
+ (if (pos? num-retries)
+ (recur (dec num-retries))
+ (throw e))))))))
(defn delete-old-datasets!
[]
diff --git a/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj b/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj
index f82df5d5ab4..8f80777c466 100644
--- a/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj
+++ b/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj
@@ -57,7 +57,11 @@
:metadata/key-constraints false
:database-routing true
:transforms/python true
- :transforms/table true}]
+ :transforms/table true
+ ;; JDBC driver always provides "NO" for the IS_GENERATEDCOLUMN JDBC metadata
+ :describe-is-generated false
+ :describe-is-nullable true
+ :describe-default-expr true}]
(defmethod driver/database-supports? [:clickhouse feature] [_driver _feature _db] supported?))
(defmethod driver/database-supports? [:clickhouse :schemas]
diff --git a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_introspection_test.clj b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_introspection_test.clj
index e8ac0dcedf4..0ded6005f08 100644
--- a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_introspection_test.clj
+++ b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_introspection_test.clj
@@ -432,8 +432,9 @@
(def ^:private base-field
{:database-is-auto-increment false
- :json-unfolding false
- :database-required true})
+ :database-is-nullable false
+ :json-unfolding false
+ :database-required true})
(deftest clickhouse-filtered-aggregate-functions-test-table-metadata
(mt/test-driver :clickhouse
diff --git a/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.clj b/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.clj
index 594717a07a7..720f46c71c4 100644
--- a/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.clj
+++ b/modules/drivers/clickhouse/test/metabase/test/data/clickhouse.clj
@@ -143,20 +143,22 @@
(defn- field->clickhouse-column
[field]
- (let [{:keys [field-name base-type pk?]} field
- ch-type (if (map? base-type)
- (:native base-type)
- (sql.tx/field-base-type->sql-type :clickhouse base-type))
- col-name (quote-name field-name)
- ch-col (cond
- (or pk? (disallowed-as-nullable? ch-type) (map? base-type))
- (format "%s %s" col-name ch-type)
-
- (= ch-type "Time")
- (format "%s Nullable(DateTime64) COMMENT 'time'" col-name)
-
- :else (format "%s Nullable(%s)" col-name ch-type))]
- ch-col))
+ (let [{:keys [field-name base-type pk? not-null? default-expr generated-expr]} field
+ ch-type (if (map? base-type)
+ (:native base-type)
+ (sql.tx/field-base-type->sql-type :clickhouse base-type))
+ col-name (quote-name field-name)
+ ch-col (cond
+ (or pk? (disallowed-as-nullable? ch-type) (map? base-type) not-null?)
+ (format "%s %s" col-name ch-type)
+
+ (= ch-type "Time")
+ (format "%s Nullable(DateTime64) COMMENT 'time'" col-name)
+
+ :else (format "%s Nullable(%s)" col-name ch-type))
+ default (when default-expr (format "DEFAULT (%s)" default-expr))
+ generated (when generated-expr (format "ALIAS (%s)" generated-expr))]
+ (str/join " " (filter some? [ch-col default generated]))))
(defn- ->comma-separated-str
[coll]
@@ -191,6 +193,9 @@
(defmethod sql.tx/session-schema :clickhouse [_] "default")
+(defmethod sql.tx/generated-column-sql :clickhouse [_ expr]
+ (format "ALIAS (%s)" expr))
+
(defn rows-without-index
"Remove the Metabase index which is the first column in the result set"
[query-result]
diff --git a/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj b/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj
index 1f40258b49b..9b1b469e390 100644
--- a/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj
+++ b/modules/drivers/druid-jdbc/test/metabase/driver/druid_jdbc_test.clj
@@ -34,6 +34,7 @@
:database-type "TIMESTAMP",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable false
:base-type :type/DateTime,
:database-position 0,
:json-unfolding false}
@@ -41,6 +42,7 @@
:database-type "BIGINT",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/BigInteger,
:database-position 10,
:json-unfolding false}
@@ -48,6 +50,7 @@
:database-type "BIGINT",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/BigInteger,
:database-position 1,
:json-unfolding false}
@@ -55,6 +58,7 @@
:database-type "COMPLEX<hyperUnique>",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/DruidHyperUnique,
:database-position 11,
:json-unfolding false}
@@ -62,6 +66,7 @@
:database-type "VARCHAR",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/Text,
:database-position 2,
:json-unfolding false}
@@ -69,6 +74,7 @@
:database-type "VARCHAR",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/Text,
:database-position 3,
:json-unfolding false}
@@ -76,6 +82,7 @@
:database-type "VARCHAR",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/Text,
:database-position 4,
:json-unfolding false}
@@ -83,6 +90,7 @@
:database-type "VARCHAR",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/Text,
:database-position 5,
:json-unfolding false}
@@ -90,6 +98,7 @@
:database-type "DOUBLE",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/Float,
:database-position 6,
:json-unfolding false}
@@ -97,6 +106,7 @@
:database-type "DOUBLE",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/Float,
:database-position 7,
:json-unfolding false}
@@ -104,6 +114,7 @@
:database-type "VARCHAR",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/Text,
:database-position 8,
:json-unfolding false}
@@ -111,6 +122,7 @@
:database-type "BIGINT",
:database-required false,
:database-is-auto-increment false,
+ :database-is-nullable true
:base-type :type/BigInteger,
:database-position 9,
:json-unfolding false}}}
diff --git a/modules/drivers/mongo/src/metabase/driver/mongo.clj b/modules/drivers/mongo/src/metabase/driver/mongo.clj
index ed2fb6290de..4de4693c3c1 100644
--- a/modules/drivers/mongo/src/metabase/driver/mongo.clj
+++ b/modules/drivers/mongo/src/metabase/driver/mongo.clj
@@ -427,6 +427,7 @@
:nested-queries true
:set-timezone true
:standard-deviation-aggregations true
+ :test/create-table-without-data false
:rename true
:test/jvm-timezone-setting false
:identifiers-with-spaces true
diff --git a/modules/drivers/oracle/src/metabase/driver/oracle.clj b/modules/drivers/oracle/src/metabase/driver/oracle.clj
index 6b34285b501..8a291413460 100644
--- a/modules/drivers/oracle/src/metabase/driver/oracle.clj
+++ b/modules/drivers/oracle/src/metabase/driver/oracle.clj
@@ -56,7 +56,10 @@
:identifiers-with-spaces true
:convert-timezone true
:expressions/date false
- :database-routing false}]
+ :database-routing false
+ :describe-default-expr true
+ :describe-is-generated true
+ :describe-is-nullable true}]
(defmethod driver/database-supports? [:oracle feature] [_driver _feature _db] supported?))
(mr/def ::details
diff --git a/modules/drivers/presto-jdbc/test/metabase/test/data/presto_jdbc.clj b/modules/drivers/presto-jdbc/test/metabase/test/data/presto_jdbc.clj
index 14eccca31a9..3719cb7c647 100644
--- a/modules/drivers/presto-jdbc/test/metabase/test/data/presto_jdbc.clj
+++ b/modules/drivers/presto-jdbc/test/metabase/test/data/presto_jdbc.clj
@@ -199,3 +199,6 @@
:else (recur)))))))
(catch Throwable _e
false))))
+
+(defmethod sql.tx/generated-column-sql :presto-jdbc [_ _] nil)
+(defmethod sql.tx/default-column-sql :presto-jdbc [_ _] nil)
diff --git a/modules/drivers/redshift/src/metabase/driver/redshift.clj b/modules/drivers/redshift/src/metabase/driver/redshift.clj
index 5af20113b9a..9815c50c744 100644
--- a/modules/drivers/redshift/src/metabase/driver/redshift.clj
+++ b/modules/drivers/redshift/src/metabase/driver/redshift.clj
@@ -47,7 +47,10 @@
:database-routing true
:metadata/table-existence-check true
:transforms/python true
- :transforms/table true}]
+ :transforms/table true
+ :describe-default-expr false
+ :describe-is-generated false
+ :describe-is-nullable false}]
(defmethod driver/database-supports? [:redshift feature] [_driver _feat _db] supported?))
;;; +----------------------------------------------------------------------------------------------------------------+
diff --git a/modules/drivers/redshift/test/metabase/test/data/redshift.clj b/modules/drivers/redshift/test/metabase/test/data/redshift.clj
index 79a6cd3285b..c10c1cbf822 100644
--- a/modules/drivers/redshift/test/metabase/test/data/redshift.clj
+++ b/modules/drivers/redshift/test/metabase/test/data/redshift.clj
@@ -349,3 +349,5 @@
(format "REVOKE ALL PRIVILEGES ON SCHEMA %s FROM %s;" schema role-name)
(format "DROP USER IF EXISTS %s" role-name)]]
(jdbc/execute! spec [statement] {:transaction? false}))))))
+
+(defmethod sql.tx/generated-column-sql :redshift [_ _] nil)
diff --git a/modules/drivers/snowflake/src/metabase/driver/snowflake.clj b/modules/drivers/snowflake/src/metabase/driver/snowflake.clj
index 446d7a15aed..a1a2c3704fe 100644
--- a/modules/drivers/snowflake/src/metabase/driver/snowflake.clj
+++ b/modules/drivers/snowflake/src/metabase/driver/snowflake.clj
@@ -61,6 +61,10 @@
:convert-timezone true
:datetime-diff true
:describe-fields false
+ :describe-default-expr true
+ ;; JDBC driver always provides "NO" for the IS_GENERATEDCOLUMN JDBC metadata
+ :describe-is-generated false
+ :describe-is-nullable true
:expression-literals true
:expressions/integer true
:expressions/text true
diff --git a/modules/drivers/snowflake/test/metabase/driver/snowflake_test.clj b/modules/drivers/snowflake/test/metabase/driver/snowflake_test.clj
index 37334e091b8..93466c12350 100644
--- a/modules/drivers/snowflake/test/metabase/driver/snowflake_test.clj
+++ b/modules/drivers/snowflake/test/metabase/driver/snowflake_test.clj
@@ -440,21 +440,23 @@
(testing "make sure describe-table uses the NAME FROM DETAILS too"
(is (= {:name "categories"
:schema "PUBLIC"
- :fields #{{:name "id"
- :database-type "NUMBER"
- :base-type :type/Number
- :pk? true
- :database-position 0
+ :fields #{{:name "id"
+ :database-type "NUMBER"
+ :base-type :type/Number
+ :pk? true
+ :database-position 0
:database-is-auto-increment true
- :database-required false
- :json-unfolding false}
- {:name "name"
- :database-type "VARCHAR"
- :base-type :type/Text
- :database-position 1
+ :database-is-nullable false
+ :database-required false
+ :json-unfolding false}
+ {:name "name"
+ :database-type "VARCHAR"
+ :base-type :type/Text
+ :database-position 1
:database-is-auto-increment false
- :database-required true
- :json-unfolding false}}}
+ :database-is-nullable false
+ :database-required true
+ :json-unfolding false}}}
(driver/describe-table :snowflake (assoc (mt/db) :name "ABC") (t2/select-one :model/Table :id (mt/id :categories))))))))
(deftest ^:parallel describe-table-fks-test
diff --git a/modules/drivers/snowflake/test/metabase/test/data/snowflake.clj b/modules/drivers/snowflake/test/metabase/test/data/snowflake.clj
index a4c486eaf41..e8e164de5af 100644
--- a/modules/drivers/snowflake/test/metabase/test/data/snowflake.clj
+++ b/modules/drivers/snowflake/test/metabase/test/data/snowflake.clj
@@ -210,6 +210,9 @@
(when (#{:count :cum-count} ag-type)
{:base_type :type/Number}))))
+(defmethod sql.tx/generated-column-sql :snowflake [_ expr]
+ (format "AS (%s)" expr))
+
(defn- setup-tracking-db!
"Idempotently create test tracking database"
[conn driver]
diff --git a/modules/drivers/sqlite/src/metabase/driver/sqlite.clj b/modules/drivers/sqlite/src/metabase/driver/sqlite.clj
index a55a9f67b7b..df5d75db306 100644
--- a/modules/drivers/sqlite/src/metabase/driver/sqlite.clj
+++ b/modules/drivers/sqlite/src/metabase/driver/sqlite.clj
@@ -46,7 +46,10 @@
:case-sensitivity-string-filter-options false
;; Index sync is turned off across the application as it is not used ATM.
:index-info false
- :database-routing true}]
+ :database-routing true
+ :describe-default-expr true
+ :describe-is-nullable true
+ :describe-is-generated true}]
(defmethod driver/database-supports? [:sqlite feature] [_driver _feature _db] supported?))
;; Every SQLite3 file starts with "SQLite Format 3"
diff --git a/modules/drivers/sqlite/test/metabase/driver/sqlite_test.clj b/modules/drivers/sqlite/test/metabase/driver/sqlite_test.clj
index fddc2552eba..64d018ca526 100644
--- a/modules/drivers/sqlite/test/metabase/driver/sqlite_test.clj
+++ b/modules/drivers/sqlite/test/metabase/driver/sqlite_test.clj
@@ -145,7 +145,9 @@
:database-position 0
:database-required false
:json-unfolding false
- :database-is-auto-increment false}}}
+ :database-is-auto-increment false
+ :database-is-nullable true
+ :database-is-generated false}}}
(driver/describe-table driver db (t2/select-one :model/Table :id (mt/id :timestamp_table)))))))))))))
(deftest select-query-datetime
diff --git a/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj b/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj
index 2d82356f440..bc28c143513 100644
--- a/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj
+++ b/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj
@@ -58,7 +58,10 @@
:metadata/table-existence-check true
:transforms/python true
:transforms/table true
- :jdbc/statements false}]
+ :jdbc/statements false
+ :describe-default-expr true
+ :describe-is-nullable true
+ :describe-is-generated true}]
(defmethod driver/database-supports? [:sqlserver feature] [_driver _feature _db] supported?))
(mu/defmethod driver/database-supports? [:sqlserver :percentile-aggregations]
diff --git a/modules/drivers/sqlserver/test/metabase/test/data/sqlserver.clj b/modules/drivers/sqlserver/test/metabase/test/data/sqlserver.clj
index eaf24abd648..0c67dcfc3cc 100644
--- a/modules/drivers/sqlserver/test/metabase/test/data/sqlserver.clj
+++ b/modules/drivers/sqlserver/test/metabase/test/data/sqlserver.clj
@@ -166,3 +166,8 @@
(sql/format
{(if materialized? :drop-materialized-view :drop-view) [[:if-exists [:raw qualified-view]]]}
:dialect (sql.qp/quote-style driver))))
+
+(defmethod sql.tx/generated-column-sql :sqlserver [_ expr]
+ (format "AS (%s)" expr))
+
+(defmethod sql.tx/generated-column-infers-type? :sqlserver [_] true)
diff --git a/modules/drivers/starburst/test/metabase/test/data/starburst.clj b/modules/drivers/starburst/test/metabase/test/data/starburst.clj
index 5404ec1ee27..c51d83be5ab 100644
--- a/modules/drivers/starburst/test/metabase/test/data/starburst.clj
+++ b/modules/drivers/starburst/test/metabase/test/data/starburst.clj
@@ -179,3 +179,6 @@
(defmethod tx/bad-connection-details :starburst
[_driver]
{:port (dec (Integer/parseInt (tx/db-test-env-var :starburst :port "8080")))})
+
+(defmethod sql.tx/generated-column-sql :starburst [_ _] nil)
+(defmethod sql.tx/default-column-sql :starburst [_ _] nil)
diff --git a/modules/drivers/vertica/src/metabase/driver/vertica.clj b/modules/drivers/vertica/src/metabase/driver/vertica.clj
index f9ca33586c6..453cc7c91a1 100644
--- a/modules/drivers/vertica/src/metabase/driver/vertica.clj
+++ b/modules/drivers/vertica/src/metabase/driver/vertica.clj
@@ -38,7 +38,9 @@
:uuid-type true
:percentile-aggregations false
:test/jvm-timezone-setting false
- :database-routing false}]
+ :database-routing false
+ :describe-is-nullable true
+ :describe-default-expr true}]
(defmethod driver/database-supports? [:vertica feature] [_driver _feature _db] supported?))
(defmethod driver/db-start-of-week :vertica
diff --git a/modules/drivers/vertica/test/metabase/test/data/vertica.clj b/modules/drivers/vertica/test/metabase/test/data/vertica.clj
index bfb3db836a1..8861f98adfc 100644
--- a/modules/drivers/vertica/test/metabase/test/data/vertica.clj
+++ b/modules/drivers/vertica/test/metabase/test/data/vertica.clj
@@ -305,3 +305,5 @@
(filter #(tx/qualified-by-db-name? physical-db-name (:name %)))
tables))))
(original-describe-database driver database)))
+
+(defmethod sql.tx/generated-column-sql :vertica [_ _] nil)
diff --git a/resources/migrations/057_update_migrations.yaml b/resources/migrations/057_update_migrations.yaml
index 9cdb6171efd..5a6a5402068 100644
--- a/resources/migrations/057_update_migrations.yaml
+++ b/resources/migrations/057_update_migrations.yaml
@@ -1906,6 +1906,82 @@ databaseChangeLog:
SET dataset_query = legacy_query
WHERE legacy_query IS NOT NULL;
+ - changeSet:
+ id: v57.2025-10-21T14:14:22
+ author: wotbrew
+ comment: Add column metabase_field.database_is_pk
+ changes:
+ - addColumn:
+ tableName: metabase_field
+ columns:
+ - column:
+ name: database_is_pk
+ remarks: Whether or not the field is part of the primary key (not user editable like semantic_type)
+ type: ${boolean.type}
+ constraints:
+ nullable: true
+ rollback:
+ - dropColumn:
+ tableName: metabase_field
+ columnName: database_is_pk
+
+ - changeSet:
+ id: v57.2025-10-21T14:14:23
+ author: wotbrew
+ comment: Add column metabase_field.database_is_nullable
+ changes:
+ - addColumn:
+ tableName: metabase_field
+ columns:
+ - column:
+ name: database_is_nullable
+ remarks: Whether or not the field will accept nulls
+ type: ${boolean.type}
+ constraints:
+ nullable: true
+ rollback:
+ - dropColumn:
+ tableName: metabase_field
+ columnName: database_is_nullable
+
+ - changeSet:
+ id: v57.2025-10-21T14:14:24
+ author: wotbrew
+ comment: Add column metabase_field.database_is_generated
+ changes:
+ - addColumn:
+ tableName: metabase_field
+ columns:
+ - column:
+ name: database_is_generated
+ remarks: Whether or not the column is computed and will not accept writes
+ type: ${boolean.type}
+ constraints:
+ nullable: true
+ rollback:
+ - dropColumn:
+ tableName: metabase_field
+ columnName: database_is_generated
+
+ - changeSet:
+ id: v57.2025-10-21T14:14:25
+ author: wotbrew
+ comment: Add column metabase_field.database_default
+ changes:
+ - addColumn:
+ tableName: metabase_field
+ columns:
+ - column:
+ name: database_default
+ remarks: The dialect specific column default expression
+ type: ${text.type}
+ constraints:
+ nullable: true
+ rollback:
+ - dropColumn:
+ tableName: metabase_field
+ columnName: database_default
+
# >>>>>>>>>> DO NOT ADD NEW MIGRATIONS BELOW THIS LINE! ADD THEM ABOVE <<<<<<<<<<
diff --git a/src/metabase/driver.clj b/src/metabase/driver.clj
index ef553e30a08..9d1be1fb443 100644
--- a/src/metabase/driver.clj
+++ b/src/metabase/driver.clj
@@ -740,6 +740,9 @@
;; Does this driver support "temporal-unit" template tags in native queries?
:native-temporal-units
+ ;; Does this driver support creating tables on their own without adding data?
+ :test/create-table-without-data
+
;; Does this driver support transforms with a table as the target?
:transforms/table
@@ -778,7 +781,16 @@
:metadata/table-writable-check
;; Does this driver support creating a java.sql.Statement via a Connection?
- :jdbc/statements})
+ :jdbc/statements
+
+ ;; Does this driver provide :database-default on (describe-fields) or (describe-table)
+ :describe-default-expr
+
+ ;; Does this driver provide :database-is-nullable on (describe-fields) or (describe-table)
+ :describe-is-nullable
+
+ ;; Does this driver provide :database-is-generated on (describe-fields) or (describe-table)
+ :describe-is-generated})
(defmulti database-supports?
"Does this driver and specific instance of a database support a certain `feature`?
@@ -820,6 +832,7 @@
:fingerprint true
:upload-with-auto-pk true
:saved-question-sandboxing true
+ :test/create-table-without-data true
:test/dynamic-dataset-loading true
:test/uuids-in-create-table-statements true
:metadata/table-existence-check false
diff --git a/src/metabase/driver/h2.clj b/src/metabase/driver/h2.clj
index abc23aae653..4bc7e529423 100644
--- a/src/metabase/driver/h2.clj
+++ b/src/metabase/driver/h2.clj
@@ -73,6 +73,9 @@
:uuid-type true
:uploads true
:database-routing true
+ :describe-is-generated true
+ :describe-is-nullable true
+ :describe-default-expr true
:metadata/table-existence-check true}]
(defmethod driver/database-supports? [:h2 feature]
[_driver _feature _database]
diff --git a/src/metabase/driver/mysql.clj b/src/metabase/driver/mysql.clj
index 961cce9227b..63fdaba8efe 100644
--- a/src/metabase/driver/mysql.clj
+++ b/src/metabase/driver/mysql.clj
@@ -93,7 +93,10 @@
:database-routing true
:metadata/table-existence-check true
:transforms/python true
- :transforms/table true}]
+ :transforms/table true
+ :describe-default-expr true
+ :describe-is-nullable true
+ :describe-is-generated 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.
@@ -1062,7 +1065,9 @@
(-> col
(update :pk? pos?)
(update :database-required pos?)
- (update :database-is-auto-increment pos?)))))
+ (update :database-is-auto-increment pos?)
+ (update :database-is-nullable pos?)
+ (update :database-is-generated pos?)))))
(defmethod sql-jdbc.sync/describe-fields-sql :mysql
[driver & {:keys [table-names details]}]
@@ -1080,6 +1085,16 @@
[:not [:= :c.extra [:inline "auto_increment"]]]]
:database-required]
[[:= :c.column_key [:inline "PRI"]] :pk?]
+ [[:= :is_nullable [:inline "YES"]] :database-is-nullable]
+ [[:if [:= [:lower :column_default] [:inline "null"]] nil :column_default] :database-default]
+
+ [[:and
+ ;; mariadb
+ [:!= :generation_expression nil]
+ ;; mysql
+ [:<> :generation_expression ""]]
+ :database-is-generated]
+
[[:nullif :c.column_comment [:inline ""]] :field-comment]]
:from [[:information_schema.columns :c]]
:where
diff --git a/src/metabase/driver/postgres.clj b/src/metabase/driver/postgres.clj
index fee07cb8118..adc25850dc3 100644
--- a/src/metabase/driver/postgres.clj
+++ b/src/metabase/driver/postgres.clj
@@ -63,6 +63,9 @@
:describe-fields true
:describe-fks true
:describe-indexes true
+ :describe-default-expr true
+ :describe-is-generated true
+ :describe-is-nullable true
:convert-timezone true
:datetime-diff true
:now true
@@ -326,10 +329,15 @@
[:and [:!= :column_default nil] [:like :column_default [:inline "%nextval(%"]]]
[:!= :is_identity [:inline "NO"]]]]]
:database-required]
+ [:column_default :database-default]
[[:or
[:and [:!= :column_default nil] [:like :column_default [:inline "%nextval(%"]]]
[:!= :is_identity [:inline "NO"]]]
- :database-is-auto-increment]]
+ :database-is-auto-increment]
+ [[:= :is_generated "ALWAYS"]
+ :database-is-generated]
+ [[:= :is_nullable [:inline "YES"]]
+ :database-is-nullable]]
:from [[:information_schema.columns :c]]
:left-join [[{:select [:tc.table_schema
:tc.table_name
@@ -363,7 +371,10 @@
[false :pk?]
[nil :field-comment]
[false :database-required]
- [false :database-is-auto-increment]]
+ [nil :database-default]
+ [false :database-is-auto-increment]
+ [false :database-is-generated]
+ [false :database-is-nullable]]
:from [[:pg_catalog.pg_class :pc]]
:join [[:pg_catalog.pg_namespace :pn] [:= :pn.oid :pc.relnamespace]
[:pg_catalog.pg_attribute :pa] [:= :pa.attrelid :pc.oid]
diff --git a/src/metabase/driver/sql_jdbc/sync/describe_table.clj b/src/metabase/driver/sql_jdbc/sync/describe_table.clj
index f51f5ec2c38..98575a41516 100644
--- a/src/metabase/driver/sql_jdbc/sync/describe_table.clj
+++ b/src/metabase/driver/sql_jdbc/sync/describe_table.clj
@@ -135,19 +135,33 @@
;; https://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getColumns(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)
#(let [default (.getString rs "COLUMN_DEF")
no-default? (contains? #{nil "NULL" "null"} default)
- nullable (.getInt rs "NULLABLE")
- not-nullable? (= 0 nullable)
- ;; IS_AUTOINCREMENT could return nil
+ ;; leave room for "", or other strings to be nil (unknown)
+ nullable ({"YES" true, "NO" false} (.getString rs "IS_NULLABLE"))
+ generated (when (driver/database-supports? driver :describe-is-generated nil) ; if not supported, we might get an inaccurate answer from IS_GENERATEDCOLUMN (e.g clickhouse)
+ ({"YES" true, "NO" false} (.getString rs "IS_GENERATEDCOLUMN")))
+ ;; IS_AUTOINCREMENT could return nil
auto-increment (.getString rs "IS_AUTOINCREMENT")
auto-increment? (= "YES" auto-increment)
no-auto-increment? (= "NO" auto-increment)
column-name (.getString rs "COLUMN_NAME")
- required? (and no-default? not-nullable? no-auto-increment?)]
+ ;; ambiguous, but preserves previous unknown == not nullable database-required behaviour
+ not-nullable (= 0 (.getInt rs "NULLABLE"))
+ required? (and no-default? not-nullable no-auto-increment?)]
(merge
{:name column-name
:database-type (.getString rs "TYPE_NAME")
:database-is-auto-increment auto-increment?
:database-required required?}
+
+ ;; in the same way drivers are free to not return these attributes, and leave them undefined
+ ;; we should treat unknown values accordingly
+ (u/remove-nils
+ {;; COLUMN_DEF = "" observed with clickhouse, druid, "" is never a valid SQL expression, so treat as undefined
+ ;; we should probably not-empty for the purposes of required, but trying to retain existing behaviour for now
+ :database-default (not-empty default)
+ :database-is-generated generated
+ :database-is-nullable nullable})
+
(when-let [remarks (.getString rs "REMARKS")]
(when-not (str/blank? remarks)
{:field-comment remarks})))))))
@@ -211,8 +225,11 @@
:name
:database-type
:field-comment
+ :database-default
:database-required
- :database-is-auto-increment])
+ :database-is-auto-increment
+ :database-is-generated
+ :database-is-nullable])
{:table-schema (:table-schema col) ;; can be nil
:base-type base-type
;; json-unfolding is true by default for JSON fields, but this can be overridden at the DB level
diff --git a/src/metabase/sync/interface.clj b/src/metabase/sync/interface.clj
index 9e59b63c041..80a5af4a7c6 100644
--- a/src/metabase/sync/interface.clj
+++ b/src/metabase/sync/interface.clj
@@ -51,7 +51,10 @@
;; TODO (Cam 8/11/25) -- this should be required to be a sequence of strings but we'll need to go fix some code
[:nfc-path {:optional true} [:maybe [:sequential [:or :keyword :string]]]]
[:custom {:optional true} :map]
+ [:database-default {:optional true} :string]
[:database-is-auto-increment {:optional true} :boolean]
+ [:database-is-generated {:optional true} :boolean]
+ [:database-is-nullable {:optional true} :boolean]
;; nullable for databases that don't support field partition
[:database-partitioned {:optional true} [:maybe :boolean]]
[:database-required {:optional true} :boolean]
diff --git a/src/metabase/sync/sync_metadata/fields/our_metadata.clj b/src/metabase/sync/sync_metadata/fields/our_metadata.clj
index b5dea249367..fa89a3e62db 100644
--- a/src/metabase/sync/sync_metadata/fields/our_metadata.clj
+++ b/src/metabase/sync/sync_metadata/fields/our_metadata.clj
@@ -19,23 +19,28 @@
(mu/defn- fields->parent-id->fields :- [:map-of common/ParentID [:set common/TableMetadataFieldWithID]]
[fields :- [:maybe [:sequential i/FieldInstance]]]
(->> (for [field fields]
- {:parent-id (:parent_id field)
- :id (:id field)
- :name (:name field)
- :database-type (:database_type field)
- :effective-type (:effective_type field)
- :coercion-strategy (:coercion_strategy field)
- :base-type (:base_type field)
- :semantic-type (:semantic_type field)
- :pk? (isa? (:semantic_type field) :type/PK)
- :field-comment (:description field)
- :json-unfolding (:json_unfolding field)
- :database-is-auto-increment (:database_is_auto_increment field)
- :position (:position field)
- :database-position (:database_position field)
- :database-partitioned (:database_partitioned field)
- :database-required (:database_required field)
- :visibility-type (:visibility_type field)})
+ (merge
+ {:parent-id (:parent_id field)
+ :id (:id field)
+ :name (:name field)
+ :database-type (:database_type field)
+ :effective-type (:effective_type field)
+ :coercion-strategy (:coercion_strategy field)
+ :base-type (:base_type field)
+ :semantic-type (:semantic_type field)
+ :field-comment (:description field)
+ :json-unfolding (:json_unfolding field)
+ :database-is-auto-increment (:database_is_auto_increment field)
+ :position (:position field)
+ :database-position (:database_position field)
+ :database-partitioned (:database_partitioned field)
+ :database-required (:database_required field)
+ :visibility-type (:visibility_type field)}
+ (u/remove-nils
+ {:pk? (:database_is_pk field)
+ :database-is-generated (:database_is_generated field)
+ :database-is-nullable (:database_is_nullable field)
+ :database-default (:database_default field)})))
;; make a map of parent-id -> set of child Fields
(group-by :parent-id)
;; remove the parent ID because the Metadata from `describe-table` won't have it. Save the results as a set
@@ -69,7 +74,9 @@
"Fetch active Fields from the Metabase application database for a given `table`."
[table :- i/TableInstance]
(t2/select [:model/Field :name :database_type :base_type :effective_type :coercion_strategy :semantic_type
- :parent_id :id :description :database_position :nfc_path :database_is_auto_increment :database_required
+ :parent_id :id :description :database_position :nfc_path
+ :database_is_auto_increment :database_required
+ :database_default :database_is_generated :database_is_nullable :database_is_pk
:database_partitioned :json_unfolding :position]
:table_id (u/the-id table)
:active true
diff --git a/src/metabase/sync/sync_metadata/fields/sync_instances.clj b/src/metabase/sync/sync_metadata/fields/sync_instances.clj
index 1c8475e4c61..57041d41b4b 100644
--- a/src/metabase/sync/sync_metadata/fields/sync_instances.clj
+++ b/src/metabase/sync/sync_metadata/fields/sync_instances.clj
@@ -46,6 +46,7 @@
(when (seq new-field-metadatas)
(t2/insert-returning-pks! :model/Field
(for [{:keys [base-type coercion-strategy database-is-auto-increment database-partitioned database-position
+ database-is-generated database-is-nullable database-default pk?
database-required database-type effective-type field-comment json-unfolding nfc-path visibility-type]
field-name :name :as field} (sort-by :database-position new-field-metadatas)
:let [semantic-type (common/semantic-type field)
@@ -79,6 +80,10 @@
:database_position database-position
:json_unfolding (or json-unfolding false)
:database_is_auto_increment (or database-is-auto-increment false)
+ :database_is_generated database-is-generated
+ :database_is_nullable database-is-nullable
+ :database_is_pk pk?
+ :database_default database-default
:database_required (or database-required false)
:database_partitioned database-partitioned ;; nullable for database that doesn't support partitioned fields
:has_field_values has-field-values
diff --git a/src/metabase/sync/sync_metadata/fields/sync_metadata.clj b/src/metabase/sync/sync_metadata/fields/sync_metadata.clj
index 6fd8d49fc26..24513559724 100644
--- a/src/metabase/sync/sync_metadata/fields/sync_metadata.clj
+++ b/src/metabase/sync/sync_metadata/fields/sync_metadata.clj
@@ -37,8 +37,12 @@
old-semantic-type :semantic-type
old-database-position :database-position
old-position :position
+ old-pk :pk?
old-database-name :name
+ old-database-default :database-default
old-database-is-auto-increment :database-is-auto-increment
+ old-database-is-generated :database-is-generated
+ old-database-is-nullable :database-is-nullable
old-db-partitioned :database-partitioned
old-db-required :database-required
old-visibility-type :visibility-type} metabase-field
@@ -47,7 +51,11 @@
new-field-comment :field-comment
new-database-position :database-position
new-database-name :name
+ new-pk :pk?
+ new-database-default :database-default
new-database-is-auto-increment :database-is-auto-increment
+ new-database-is-generated :database-is-generated
+ new-database-is-nullable :database-is-nullable
new-db-partitioned :database-partitioned
new-db-required :database-required} field-metadata
new-visibility-type (compute-new-visibility-type database field-metadata)
@@ -78,7 +86,11 @@
;; different they have the same canonical representation (lower-casing at the moment).
new-name? (not= old-database-name new-database-name)
+ new-pk? (not= old-pk new-pk)
+ new-db-default? (not= old-database-default new-database-default)
new-db-auto-incremented? (not= old-database-is-auto-increment new-database-is-auto-increment)
+ new-db-generated? (not= old-database-is-generated new-database-is-generated)
+ new-db-nullable? (not= old-database-is-nullable new-database-is-nullable)
new-db-partitioned? (not= new-db-partitioned old-db-partitioned)
new-db-required? (not= old-db-required new-db-required)
new-visibility-type? (not= old-visibility-type new-visibility-type)
@@ -137,12 +149,41 @@
old-database-name
new-database-name)
{:name new-database-name})
+ (when new-pk?
+ ;; this guard avoids spamming logs with pk changes when people first upgrade to support database_is_pk
+ (when (or ;; if we have any value for the old database_is_pk we have upgraded already, and can log regardless
+ (some? old-pk)
+ ;; otherwise, log only if logical pk status has changed
+ (not= new-pk (= old-semantic-type :type/PK)))
+ (log/infof "Database pk of %s has changed from '%s' to '%s'"
+ (common/field-metadata-name-for-logging table metabase-field)
+ old-pk
+ new-pk))
+ {:database_is_pk new-pk})
(when new-db-auto-incremented?
(log/infof "Database auto incremented of %s has changed from '%s' to '%s'."
(common/field-metadata-name-for-logging table metabase-field)
old-database-is-auto-increment
new-database-is-auto-increment)
{:database_is_auto_increment new-database-is-auto-increment})
+ (when new-db-generated?
+ (log/infof "Database generated of %s has changed from '%s' to '%s'."
+ (common/field-metadata-name-for-logging table metabase-field)
+ old-database-is-generated
+ new-database-is-generated)
+ {:database_is_generated new-database-is-generated})
+ (when new-db-nullable?
+ (log/infof "Database nullable of %s has changed from '%s' to '%s'."
+ (common/field-metadata-name-for-logging table metabase-field)
+ old-database-is-nullable
+ new-database-is-nullable)
+ {:database_is_nullable new-database-is-nullable})
+ (when new-db-default?
+ (log/infof "Database default of %s has changed from '%s' to '%s'."
+ (common/field-metadata-name-for-logging table metabase-field)
+ old-database-default
+ new-database-default)
+ {:database_default new-database-default})
(when new-db-partitioned?
(log/infof "Database partitioned of %s has changed from '%s' to '%s'."
(common/field-metadata-name-for-logging table metabase-field)
diff --git a/src/metabase/warehouse_schema/models/field.clj b/src/metabase/warehouse_schema/models/field.clj
index 35ea1c377bf..da9d37ff0e3 100644
--- a/src/metabase/warehouse_schema/models/field.clj
+++ b/src/metabase/warehouse_schema/models/field.clj
@@ -420,8 +420,9 @@
(disj this))))
(defmethod serdes/make-spec "Field" [_model-name opts]
- {:copy [:active :base_type :caveats :coercion_strategy :custom_position :database_indexed
- :database_is_auto_increment :database_partitioned :database_position :database_required :database_type
+ {:copy [:active :base_type :caveats :coercion_strategy :custom_position :database_default :database_indexed
+ :database_is_auto_increment :database_is_generated :database_is_nullable :database_is_pk
+ :database_partitioned :database_position :database_required :database_type
:description :display_name :effective_type :has_field_values :is_defective_duplicate
:json_unfolding :name :nfc_path :points_of_interest :position :preview_display :semantic_type :settings
:unique_field_helper :visibility_type]
diff --git a/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj b/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj
index 7d5f2ee34ac..4adf22c6eb7 100644
--- a/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj
+++ b/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj
@@ -58,6 +58,8 @@
:pk? true
:database-required false
:database-is-auto-increment true
+ :database-is-generated false
+ :database-is-nullable false
:json-unfolding false}
{:name "NAME"
:database-type "CHARACTER VARYING"
@@ -65,6 +67,8 @@
:database-position 1
:database-required false
:database-is-auto-increment false
+ :database-is-generated false
+ :database-is-nullable true
:json-unfolding false}
{:name "CATEGORY_ID"
:database-type "INTEGER"
@@ -72,6 +76,8 @@
:database-position 2
:database-required false
:database-is-auto-increment false
+ :database-is-generated false
+ :database-is-nullable true
:json-unfolding false}
{:name "LATITUDE"
:database-type "DOUBLE PRECISION"
@@ -79,6 +85,8 @@
:database-position 3
:database-required false
:database-is-auto-increment false
+ :database-is-generated false
+ :database-is-nullable true
:json-unfolding false}
{:name "LONGITUDE"
:database-type "DOUBLE PRECISION"
@@ -86,6 +94,8 @@
:database-position 4
:database-required false
:database-is-auto-increment false
+ :database-is-generated false
+ :database-is-nullable true
:json-unfolding false}
{:name "PRICE"
:database-type "INTEGER"
@@ -93,6 +103,8 @@
:database-position 5
:database-required false
:database-is-auto-increment false
+ :database-is-generated false
+ :database-is-nullable true
:json-unfolding false}}}
(driver/describe-table :h2 (mt/db) {:name "VENUES"})))))
@@ -109,28 +121,34 @@
"GRANT ALL ON \"employee_counter\" TO GUEST;"]]
(jdbc/execute! one-off-dbs/*conn* [statement]))
(sync/sync-database! (mt/db))
- (is (= {:fields #{{:base-type :type/Integer
+ (is (= {:fields #{{:base-type :type/Integer
:database-is-auto-increment true
- :database-position 0
- :database-required false
- :database-type "INTEGER"
- :name "id"
- :pk? true
- :json-unfolding false}
- {:base-type :type/Integer
+ :database-is-generated false
+ :database-is-nullable false
+ :database-position 0
+ :database-required false
+ :database-type "INTEGER"
+ :name "id"
+ :pk? true
+ :json-unfolding false}
+ {:base-type :type/Integer
:database-is-auto-increment true
- :database-position 1
- :database-required false
- :database-type "INTEGER"
- :name "count"
- :json-unfolding false}
- {:base-type :type/Integer
+ :database-is-generated false
+ :database-is-nullable false
+ :database-position 1
+ :database-required false
+ :database-type "INTEGER"
+ :name "count"
+ :json-unfolding false}
+ {:base-type :type/Integer
:database-is-auto-increment false
- :database-position 2
- :database-required true
- :database-type "INTEGER"
- :name "rank"
- :json-unfolding false}}
+ :database-is-generated false
+ :database-is-nullable false
+ :database-position 2
+ :database-required true
+ :database-type "INTEGER"
+ :name "rank"
+ :json-unfolding false}}
:name "employee_counter"}
(sql-jdbc.describe-table/describe-table :h2 (mt/id) {:name "employee_counter"}))))))
diff --git a/test/metabase/driver_test.clj b/test/metabase/driver_test.clj
index fbbffa1455d..e0e8ca1059d 100644
--- a/test/metabase/driver_test.clj
+++ b/test/metabase/driver_test.clj
@@ -297,6 +297,52 @@
:base-type #(isa? % :type/Number)}]
(describe-fields-for-table (mt/db) table))))))))
+(deftest ^:parallel describe-fields-returns-nullability-test
+ (mt/test-drivers (mt/normal-drivers-with-feature :test/dynamic-dataset-loading :test/create-table-without-data)
+ (mt/dataset nullable-db
+ (let [table (t2/select-one :model/Table :id (mt/id :nullable))
+ fields (describe-fields-for-table (mt/db) table)
+ [a b c] (->> ["a" "b" "c"]
+ (map #(ddl.i/format-name driver/*driver* %))
+ (map (u/index-by :name fields)))]
+ ;; this test only properties of the field-meta returned by the driver, not whether it syncs, for that see sync_metadata/fields_test.clj
+ (if (driver/database-supports? driver/*driver* :describe-is-nullable (mt/db))
+ (testing ":database-is-nullable should be provided"
+ (is (= [false true false] (mapv :database-is-nullable [a b c]))))
+ (testing ":database-is-nullable should remain unspecified"
+ (is (= [nil nil nil] (mapv :database-is-nullable [a b c])))))))))
+
+(deftest ^:parallel describe-fields-returns-default-expr-test
+ (mt/test-drivers (mt/normal-drivers-with-feature :test/dynamic-dataset-loading :test/create-table-without-data)
+ (mt/dataset default-expr-db
+ (let [table (t2/select-one :model/Table :id (mt/id :default_expr))
+ fields (describe-fields-for-table (mt/db) table)
+ [a b c] (->> ["a" "b" "c"]
+ (map #(ddl.i/format-name driver/*driver* %))
+ (map (u/index-by :name fields)))]
+ ;; this test only properties of the field-meta returned by the driver, not whether it syncs, for that see sync_metadata/fields_test.clj
+ (if (driver/database-supports? driver/*driver* :describe-default-expr (mt/db))
+ (testing ":database-default should be provided"
+ ;; SQL Server likes to add some parens
+ (is (=? [nil #"\(*42\)*" nil] (mapv :database-default [a b c]))))
+ (testing ":database-default should remain unspecified"
+ (is (= [nil nil nil] (mapv :database-default [a b c])))))))))
+
+(deftest ^:parallel describe-fields-returns-is-generated-test
+ (mt/test-drivers (mt/normal-drivers-with-feature :test/dynamic-dataset-loading :test/create-table-without-data)
+ (mt/dataset generated-column-db
+ (let [table (t2/select-one :model/Table :id (mt/id :generated_column))
+ fields (describe-fields-for-table (mt/db) table)
+ [a b c] (->> ["a" "b" "c"]
+ (map #(ddl.i/format-name driver/*driver* %))
+ (map (u/index-by :name fields)))]
+ ;; this test only properties of the field-meta returned by the driver, not whether it syncs, for that see sync_metadata/fields_test.clj
+ (if (driver/database-supports? driver/*driver* :describe-is-generated (mt/db))
+ (testing ":database-is-generated should be provided"
+ (is (= [false true false] (mapv :database-is-generated [a b c]))))
+ (testing ":database-is-generated should remain unspecified"
+ (is (= [nil nil nil] (mapv :database-is-generated [a b c])))))))))
+
(deftest ^:parallel describe-table-fks-test
(testing "`describe-table-fks` should work for drivers that do not support `describe-fks`"
(mt/test-drivers (set/difference (mt/normal-drivers-with-feature :metadata/key-constraints)
diff --git a/test/metabase/sync/sync_metadata/fields_test.clj b/test/metabase/sync/sync_metadata/fields_test.clj
index 6ed8014389e..c12aaaa2a03 100644
--- a/test/metabase/sync/sync_metadata/fields_test.clj
+++ b/test/metabase/sync/sync_metadata/fields_test.clj
@@ -206,27 +206,32 @@
(deftest pk-sync-test
(testing "Test PK Syncing"
(mt/with-temp-copy-of-db
- (letfn [(get-semantic-type [] (t2/select-one-fn :semantic_type :model/Field, :id (mt/id :venues :id)))]
+ (letfn [(get-pk-details [] (t2/select-one [:model/Field :semantic_type :database_is_pk], :id (mt/id :venues :id)))]
(testing "Semantic type should be :id to begin with"
- (is (= :type/PK
- (get-semantic-type))))
+ (is (= {:database_is_pk true
+ :semantic_type :type/PK}
+ (get-pk-details))))
(testing "Clear out the semantic type"
(t2/update! :model/Field (mt/id :venues :id) {:semantic_type nil})
- (is (= nil
- (get-semantic-type))))
+ (is (= {:database_is_pk true
+ :semantic_type nil}
+ (get-pk-details))))
(testing "Calling sync-table! should set the semantic type again"
(sync/sync-table! (t2/select-one :model/Table :id (mt/id :venues)))
- (is (= :type/PK
- (get-semantic-type))))
+ (is (= {:database_is_pk true
+ :semantic_type :type/PK}
+ (get-pk-details))))
(testing "sync-table! should *not* change the semantic type of fields that are marked with a different type"
(t2/update! :model/Field (mt/id :venues :id) {:semantic_type :type/Latitude})
- (is (= :type/Latitude
- (get-semantic-type))))
+ (is (= {:database_is_pk true
+ :semantic_type :type/Latitude}
+ (get-pk-details))))
(testing "Make sure that sync-table runs set-table-pks-if-needed!"
(t2/update! :model/Field (mt/id :venues :id) {:semantic_type nil})
(sync/sync-table! (t2/select-one :model/Table :id (mt/id :venues)))
- (is (= :type/PK
- (get-semantic-type))))))))
+ (is (= {:database_is_pk true
+ :semantic_type :type/PK}
+ (get-pk-details))))))))
(deftest fk-relationships-test
(testing "Check that Foreign Key relationships were created on sync as we expect"
@@ -541,3 +546,33 @@
(let [field-after-sync (t2/select-one :model/Field :id (u/the-id flocks-example-bird-name-field))]
(is (= :type/FK (:semantic_type field-after-sync)))
(is (= (u/the-id birds-example-name-field) (:fk_target_field_id field-after-sync)))))))))
+
+(deftest database-default-test
+ (with-test-db
+ (let [ddl "CREATE TABLE t (a INTEGER DEFAULT 42, b INTEGER NULL)"]
+ (jdbc/execute! one-off-dbs/*conn* [ddl])
+ (sync/sync-database! (mt/db))
+ (let [table (t2/select-one :model/Table :db_id (mt/id) :name "T")
+ {a "A", b "B"} (u/index-by :name (t2/select :model/Field :table_id (:id table)))]
+ (is (= "42" (:database_default a)))
+ (is (nil? (:database_default b)))))))
+
+(deftest database-generated-test
+ (with-test-db
+ (let [ddl "CREATE TABLE t (a INTEGER GENERATED ALWAYS AS 42, b INTEGER NULL)"]
+ (jdbc/execute! one-off-dbs/*conn* [ddl])
+ (sync/sync-database! (mt/db))
+ (let [table (t2/select-one :model/Table :db_id (mt/id) :name "T")
+ {a "A", b "B"} (u/index-by :name (t2/select :model/Field :table_id (:id table)))]
+ (is (true? (:database_is_generated a)))
+ (is (false? (:database_is_generated b)))))))
+
+(deftest database-nullable-test
+ (with-test-db
+ (let [ddl "CREATE TABLE t (a INTEGER NULL, b INTEGER NOT NULL)"]
+ (jdbc/execute! one-off-dbs/*conn* [ddl])
+ (sync/sync-database! (mt/db))
+ (let [table (t2/select-one :model/Table :db_id (mt/id) :name "T")
+ {a "A", b "B"} (u/index-by :name (t2/select :model/Field :table_id (:id table)))]
+ (is (true? (:database_is_nullable a)))
+ (is (false? (:database_is_nullable b)))))))
diff --git a/test/metabase/test/data/dataset_definitions.clj b/test/metabase/test/data/dataset_definitions.clj
index 9fac4e24b65..2c1807434e8 100644
--- a/test/metabase/test/data/dataset_definitions.clj
+++ b/test/metabase/test/data/dataset_definitions.clj
@@ -302,3 +302,24 @@
[2 2.6 2.4]
[3 3.6 3.3]
[4 4.6 4.0]]]])
+
+(tx/defdataset nullable-db
+ [["nullable"
+ [{:field-name "a" :base-type :type/Integer, :pk? true :not-null? true}
+ {:field-name "b" :base-type :type/Integer, :not-null? false}
+ {:field-name "c" :base-type :type/Integer, :not-null? true}]
+ []]])
+
+(tx/defdataset default-expr-db
+ [["default_expr"
+ [{:field-name "a" :base-type :type/Integer, :pk? true}
+ {:field-name "b" :base-type :type/Integer, :default-expr "42"}
+ {:field-name "c" :base-type :type/Integer}]
+ []]])
+
+(tx/defdataset generated-column-db
+ [["generated_column"
+ [{:field-name "a" :base-type :type/Integer, :pk? true}
+ {:field-name "b" :base-type :type/Integer, :generated-expr "42"}
+ {:field-name "c" :base-type :type/Integer}]
+ []]])
diff --git a/test/metabase/test/data/interface.clj b/test/metabase/test/data/interface.clj
index 8755971e7bf..ee320e2df48 100644
--- a/test/metabase/test/data/interface.clj
+++ b/test/metabase/test/data/interface.clj
@@ -79,6 +79,8 @@
[:not-null? {:optional true} [:maybe :boolean]]
[:unique? {:optional true} [:maybe :boolean]]
[:pk? {:optional true} [:maybe :boolean]]
+ [:default-expr {:optional true} [:maybe :string]]
+ [:generated-expr {:optional true} [:maybe :string]]
;; should we create an index for this field?
[:indexed? {:optional true} [:maybe :boolean]]
[:semantic-type {:optional true} [:maybe ms/FieldSemanticOrRelationType]]
diff --git a/test/metabase/test/data/postgres.clj b/test/metabase/test/data/postgres.clj
index 9d358f683bd..14fef2d638a 100644
--- a/test/metabase/test/data/postgres.clj
+++ b/test/metabase/test/data/postgres.clj
@@ -188,3 +188,6 @@
(sql-jdbc.tx/drop-if-exists-and-create-roles! driver details roles)
(grant-table-perms-to-roles! driver details roles)
(sql-jdbc.tx/grant-roles-to-user! driver details roles user-name))
+
+(defmethod sql.tx/generated-column-sql :postgres [_ expr]
+ (format "GENERATED ALWAYS AS (%s) STORED" expr))
diff --git a/test/metabase/test/data/sql.clj b/test/metabase/test/data/sql.clj
index 0f2e84426e1..801fdbf0c71 100644
--- a/test/metabase/test/data/sql.clj
+++ b/test/metabase/test/data/sql.clj
@@ -240,28 +240,70 @@
(str/join ", " (map #(format-and-quote-field-name driver %) field-names))
(if condition (str " WHERE " condition) ""))))
+(defmulti generated-column-sql
+ "Return the driver-specific equivalent of 'GENERATED ALWAYS AS $expr' (SQL:2003) to be appended to a column definition.
+ The expression should be given as a string.
+
+ Implementor notes:
+ If a driver does not support adding generated columns for tests, return nil."
+ {:arglists '([driver expr])}
+ tx/dispatch-on-driver-with-test-extensions
+ :hierarchy #'driver/hierarchy)
+
+(defmethod generated-column-sql :default
+ [_ expr]
+ (format "GENERATED ALWAYS AS (%s)" expr))
+
+(defmulti generated-column-infers-type?
+ "Some databases (SQL-Server) do not specify the types of generated columns."
+ {:arglists '([driver])}
+ tx/dispatch-on-driver-with-test-extensions
+ :hierarchy #'driver/hierarchy)
+
+(defmethod generated-column-infers-type? :default
+ [_]
+ false)
+
+(defmulti default-column-sql
+ "Return the driver-specific equivalent of 'DEFAULT $expr' (SQL:92) to be appended to a column definition.
+ The expression should be given as a string.
+
+ If the driver does not support default columns for tests, return nil."
+ {:arglists '([driver expr])}
+ tx/dispatch-on-driver-with-test-extensions
+ :hierarchy #'driver/hierarchy)
+
+(defmethod default-column-sql :default [_ expr]
+ (format "DEFAULT (%s)" expr))
+
(defn- field-definition-sql
- [driver {:keys [field-name base-type field-comment not-null? unique?], :as field-definition}]
- (let [field-name (format-and-quote-field-name driver field-name)
- field-type (or (cond
- (and (map? base-type) (contains? base-type :native))
- (:native base-type)
-
- (and (map? base-type) (contains? base-type :natives))
- (get-in base-type [:natives driver])
-
- base-type
- (field-base-type->sql-type driver base-type))
- (throw (ex-info (format "Missing datatype for field %s for driver: %s"
- field-name driver)
- {:field field-definition
- :driver driver})))
+ [driver {:keys [field-name base-type field-comment not-null? unique? default-expr generated-expr], :as field-definition}]
+ (let [field-name (format-and-quote-field-name driver field-name)
+ field-type (or (cond
+ (and (map? base-type) (contains? base-type :native))
+ (:native base-type)
+
+ (and (map? base-type) (contains? base-type :natives))
+ (get-in base-type [:natives driver])
+
+ base-type
+ (field-base-type->sql-type driver base-type))
+ (throw (ex-info (format "Missing datatype for field %s for driver: %s"
+ field-name driver)
+ {:field field-definition
+ :driver driver})))
not-null (when not-null?
"NOT NULL")
unique (when unique?
"UNIQUE")
+ default (when default-expr
+ (default-column-sql driver default-expr))
+ generated (when generated-expr
+ (generated-column-sql driver generated-expr))
+ infer-type (and generated-expr (generated-column-infers-type? driver))
+ field-type' (when-not infer-type field-type)
inline-comment (inline-column-comment-sql driver field-comment)]
- (str/join " " (filter some? [field-name field-type not-null unique inline-comment]))))
+ (str/join " " (filter some? [field-name field-type' not-null default generated unique inline-comment]))))
(defn fielddefs->pk-field-names
"Find the pk field names in fieldefs"
diff --git a/test/metabase/test/data/sql_jdbc/load_data.clj b/test/metabase/test/data/sql_jdbc/load_data.clj
index aad1a38c5bb..0a103e952d4 100644
--- a/test/metabase/test/data/sql_jdbc/load_data.clj
+++ b/test/metabase/test/data/sql_jdbc/load_data.clj
@@ -135,21 +135,23 @@
chunk-xform)]
(reify clojure.lang.IReduceInit
(reduce [_this rf init]
- (let [rf (xform rf)]
- (if chunk-size
- (transduce
- (partition-all chunk-size)
- ;; we are very deliberately not passing `rf` directly here, because calling the completing arity with it
- ;; breaks things since we're not supposed to be doing that inside `reduce`. We have to use `transduce` here
- ;; to get the `partition-all` transducer to work correctly tho which is why we're not just using reduce
- (fn
- ([acc]
- acc)
- ([acc chunk]
- (rf acc chunk)))
- init
- rows)
- (rf init rows)))))))
+ (if (empty? rows)
+ init
+ (let [rf (xform rf)]
+ (if chunk-size
+ (transduce
+ (partition-all chunk-size)
+ ;; we are very deliberately not passing `rf` directly here, because calling the completing arity with it
+ ;; breaks things since we're not supposed to be doing that inside `reduce`. We have to use `transduce` here
+ ;; to get the `partition-all` transducer to work correctly tho which is why we're not just using reduce
+ (fn
+ ([acc]
+ acc)
+ ([acc chunk]
+ (rf acc chunk)))
+ init
+ rows)
+ (rf init rows))))))))
(mu/defn- reducible-chunks :- (lib.schema.common/instance-of-class clojure.lang.IReduceInit)
[driver :- :keyword
diff --git a/test/metabase/test/mock/toucanery.clj b/test/metabase/test/mock/toucanery.clj
index 0d25b680366..34834d8caf3 100644
--- a/test/metabase/test/mock/toucanery.clj
+++ b/test/metabase/test/mock/toucanery.clj
@@ -16,6 +16,7 @@
:json-unfolding false
:database-is-auto-increment true}
{:name "ts"
+ :pk? false
:database-type "BIGINT"
:base-type :type/BigInteger
:effective-type :type/DateTime
@@ -23,42 +24,50 @@
:json-unfolding false
:database-is-auto-increment false}
{:name "toucan"
+ :pk? false
:database-type "OBJECT"
:base-type :type/Dictionary
:json-unfolding false
:database-is-auto-increment false
:nested-fields #{{:name "name"
+ :pk? false
:database-type "VARCHAR"
:base-type :type/Text
:json-unfolding false
:database-is-auto-increment false}
{:name "details"
+ :pk? false
:database-type "OBJECT"
:base-type :type/Dictionary
:json-unfolding false
:database-is-auto-increment false
:nested-fields #{{:name "age"
+ :pk? false
:database-type "INT"
:database-is-auto-increment false
:json-unfolding false
:base-type :type/Integer}
{:name "weight"
+ :pk? false
:database-type "DECIMAL"
:database-is-auto-increment false
:json-unfolding false
:semantic-type :type/Category
:base-type :type/Decimal}}}}}
{:name "buyer"
+ :pk? false
:database-type "OBJECT"
:database-is-auto-increment false
:json-unfolding false
:base-type :type/Dictionary
:nested-fields #{{:name "name"
+ :pk? false
:database-type "VARCHAR"
:json-unfolding false
:base-type :type/Text
:database-is-auto-increment false}
{:name "cc"
+ :pk? false
:database-type "VARCHAR"
:json-unfolding false
:base-type :type/Text
@@ -66,11 +75,13 @@
"employees" {:name "employees"
:schema nil
:fields #{{:name "id"
+ :pk? false
:database-type "SERIAL"
:json-unfolding false
:database-is-auto-increment true
:base-type :type/Integer}
{:name "name"
+ :pk? false
:database-type "VARCHAR"
:json-unfolding false
:database-is-auto-increment false
@@ -118,18 +129,19 @@
[(merge mock.util/table-defaults
{:name "employees"
:fields [(merge mock.util/field-defaults
- {:name "name"
- :display_name "Name"
- :database_type "VARCHAR"
- :base_type :type/Text
- :semantic_type :type/Name})
+ {:name "name"
+ :display_name "Name"
+ :database_type "VARCHAR"
+ :base_type :type/Text
+ :semantic_type :type/Name})
(merge mock.util/field-defaults
- {:name "id"
- :display_name "ID"
- :database_type "SERIAL"
- :base_type :type/Integer
+ {:name "id"
+ :display_name "ID"
+ :database_type "SERIAL"
+ :base_type :type/Integer
:database_is_auto_increment true
- :semantic_type :type/PK})]
+ :database_is_pk true
+ :semantic_type :type/PK})]
:display_name "Employees"})
(merge mock.util/table-defaults
{:name "transactions"
diff --git a/test/metabase/test/mock/util.clj b/test/metabase/test/mock/util.clj
index 8cc416baa8a..20b3bb72676 100644
--- a/test/metabase/test/mock/util.clj
+++ b/test/metabase/test/mock/util.clj
@@ -17,24 +17,28 @@
:created_at true})
(def field-defaults
- {:description nil
- :table_id true
- :caveats nil
- :points_of_interest nil
- :fk_target_field_id false
+ {:description nil
+ :table_id true
+ :caveats nil
+ :points_of_interest nil
+ :fk_target_field_id false
+ :database_default nil
:database_is_auto_increment false
- :updated_at true
- :active true
- :nfc_path nil
- :parent_id false
- :semantic_type nil
- :id true
- :last_analyzed true
- :position 0
- :visibility_type :normal
- :preview_display true
- :created_at true
- :json_unfolding false})
+ :database_is_generated false
+ :database_is_nullable false
+ :database_is_pk false
+ :updated_at true
+ :active true
+ :nfc_path nil
+ :parent_id false
+ :semantic_type nil
+ :id true
+ :last_analyzed true
+ :position 0
+ :visibility_type :normal
+ :preview_display true
+ :created_at true
+ :json_unfolding false})
(def pulse-channel-defaults
{:schedule_frame nil
diff --git a/test/metabase/warehouse_schema/api/table_test.clj b/test/metabase/warehouse_schema/api/table_test.clj
index f07ac68df8d..10fe0cc88da 100644
--- a/test/metabase/warehouse_schema/api/table_test.clj
+++ b/test/metabase/warehouse_schema/api/table_test.clj
@@ -83,7 +83,8 @@
(select-keys
field
[:created_at :fingerprint :fingerprint_version :fk_target_field_id :id :last_analyzed :updated_at
- :database_required :database_is_auto_increment :entity_id])))
+ :database_required :database_is_auto_increment :database_is_pk :database_is_generated :database_is_nullable
+ :entity_id])))
(deftest ^:parallel list-table-test
(testing "GET /api/table"
diff --git a/test/metabase/warehouses/api_test.clj b/test/metabase/warehouses/api_test.clj
index 2cefad064a4..410431ba333 100644
--- a/test/metabase/warehouses/api_test.clj
+++ b/test/metabase/warehouses/api_test.clj
@@ -688,7 +688,10 @@
:database_required false
;; Index sync is turned off across the application as it is not used ATM.
#_#_:database_indexed true
- :database_is_auto_increment true})
+ :database_is_auto_increment true
+ :database_is_generated false
+ :database_is_nullable false
+ :database_is_pk true})
(merge
(field-details (t2/select-one :model/Field :id (mt/id :categories :name)))
{:table_id (mt/id :categories)
@@ -704,7 +707,10 @@
:database_required true
;; Index sync is turned off across the application as it is not used ATM.
#_#_:database_indexed false
- :database_is_auto_increment false})]
+ :database_is_auto_increment false
+ :database_is_generated false
+ :database_is_nullable false
+ :database_is_pk nil})]
:segments []
:metrics []
:id (mt/id :categories)
diff --git a/test_resources/serialization_baseline/databases/My Database/tables/Schemaless Table/fields/Some Field.yaml b/test_resources/serialization_baseline/databases/My Database/tables/Schemaless Table/fields/Some Field.yaml
index 10feab82e6b..d338968741a 100644
--- a/test_resources/serialization_baseline/databases/My Database/tables/Schemaless Table/fields/Some Field.yaml
+++ b/test_resources/serialization_baseline/databases/My Database/tables/Schemaless Table/fields/Some Field.yaml
@@ -35,5 +35,9 @@ serdes/meta:
model: Table
- id: Some Field
model: Field
+database_default: null
database_indexed: null
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/ID.yaml
index 2af6d1f1a34..c29187b40d7 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/NAME.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/NAME.yaml
index c03a288afca..bb80deb5cff 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/NAME.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CATEGORIES/fields/NAME.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: NAME
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/DATE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/DATE.yaml
index 4ce638a5536..444d9bd7be9 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/DATE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/DATE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: DATE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/ID.yaml
index 73c2932d88d..168528a8537 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/USER_ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/USER_ID.yaml
index 997e86fe98c..79c3330fddc 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/USER_ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/USER_ID.yaml
@@ -41,5 +41,9 @@ serdes/meta:
model: Table
- id: USER_ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/VENUE_ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/VENUE_ID.yaml
index e5bac3f98df..d891fb836e5 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/VENUE_ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/CHECKINS/fields/VENUE_ID.yaml
@@ -41,5 +41,9 @@ serdes/meta:
model: Table
- id: VENUE_ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/CREATED_AT.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/CREATED_AT.yaml
index 8e931f4a7d9..45ff8c99485 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/CREATED_AT.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/CREATED_AT.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: CREATED_AT
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/DISCOUNT.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/DISCOUNT.yaml
index a675db2ce15..a454cc9b4a2 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/DISCOUNT.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/DISCOUNT.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: DISCOUNT
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/ID.yaml
index e46b8640bfa..3833bcabf34 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/PRODUCT_ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/PRODUCT_ID.yaml
index a4aed186237..39a6da0dadc 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/PRODUCT_ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/PRODUCT_ID.yaml
@@ -41,5 +41,9 @@ serdes/meta:
model: Table
- id: PRODUCT_ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/QUANTITY.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/QUANTITY.yaml
index a3389f1d882..89bec6a4491 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/QUANTITY.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/QUANTITY.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: QUANTITY
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/SUBTOTAL.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/SUBTOTAL.yaml
index ca1b55e5b1a..2025c6c6c7e 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/SUBTOTAL.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/SUBTOTAL.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: SUBTOTAL
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TAX.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TAX.yaml
index be5240cc8b5..802bbcb9881 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TAX.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TAX.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: TAX
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TOTAL.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TOTAL.yaml
index e7c8392665e..6b4b5004284 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TOTAL.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/TOTAL.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: TOTAL
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/USER_ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/USER_ID.yaml
index 73e40abaa04..d40cee5a463 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/USER_ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/ORDERS/fields/USER_ID.yaml
@@ -41,5 +41,9 @@ serdes/meta:
model: Table
- id: USER_ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ADDRESS.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ADDRESS.yaml
index 16442677297..6b4821c45e0 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ADDRESS.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ADDRESS.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ADDRESS
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/BIRTH_DATE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/BIRTH_DATE.yaml
index 450ea29e406..107a6651090 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/BIRTH_DATE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/BIRTH_DATE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: BIRTH_DATE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CITY.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CITY.yaml
index 99ffea1f110..d1321c0b228 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CITY.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CITY.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: CITY
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CREATED_AT.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CREATED_AT.yaml
index b9773a41acb..fc080399bb8 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CREATED_AT.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/CREATED_AT.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: CREATED_AT
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/EMAIL.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/EMAIL.yaml
index 675c6b1d9f1..4334af77dce 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/EMAIL.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/EMAIL.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: EMAIL
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ID.yaml
index ec9dc917d68..4eb876a19ed 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LATITUDE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LATITUDE.yaml
index a8bec14b91c..8aad856df3a 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LATITUDE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LATITUDE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: LATITUDE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LONGITUDE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LONGITUDE.yaml
index 52876f82c07..1efd37c0332 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LONGITUDE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/LONGITUDE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: LONGITUDE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/NAME.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/NAME.yaml
index 1958d2144f6..af1b9fda47a 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/NAME.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/NAME.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: NAME
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/PASSWORD.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/PASSWORD.yaml
index de7cbb9d4d1..44d226c3074 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/PASSWORD.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/PASSWORD.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: PASSWORD
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/SOURCE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/SOURCE.yaml
index e7a1babf777..25c03aa2ae9 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/SOURCE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/SOURCE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: SOURCE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/STATE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/STATE.yaml
index eb47750b8c0..45f8ce48b5d 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/STATE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/STATE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: STATE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ZIP.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ZIP.yaml
index a519b9c243b..998e181ceb1 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ZIP.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PEOPLE/fields/ZIP.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ZIP
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CATEGORY.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CATEGORY.yaml
index 7e8048a65e2..58d680f0e94 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CATEGORY.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CATEGORY.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: CATEGORY
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CREATED_AT.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CREATED_AT.yaml
index 04e1a7b3795..8eadfcea1b9 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CREATED_AT.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/CREATED_AT.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: CREATED_AT
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/EAN.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/EAN.yaml
index 62b0b8afbee..96a71e73999 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/EAN.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/EAN.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: EAN
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/ID.yaml
index f880ccb5af3..4d773be10e6 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/PRICE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/PRICE.yaml
index 3254baac657..e1a7e137317 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/PRICE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/PRICE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: PRICE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/RATING.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/RATING.yaml
index 246ebbb5791..2266925039f 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/RATING.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/RATING.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: RATING
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/TITLE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/TITLE.yaml
index ab322aad4f3..b2bfc3f1e46 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/TITLE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/TITLE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: TITLE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/VENDOR.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/VENDOR.yaml
index 51a4494df0e..452e8de8cdd 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/VENDOR.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/PRODUCTS/fields/VENDOR.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: VENDOR
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/BODY.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/BODY.yaml
index c69ff60cfc7..a78c4e488f0 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/BODY.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/BODY.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: BODY
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/CREATED_AT.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/CREATED_AT.yaml
index 429ac9f1933..47e5da07812 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/CREATED_AT.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/CREATED_AT.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: CREATED_AT
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/ID.yaml
index cb393180de1..d4c2d74c46b 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/PRODUCT_ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/PRODUCT_ID.yaml
index 37ceb6de7bb..ded8e91c2f3 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/PRODUCT_ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/PRODUCT_ID.yaml
@@ -41,5 +41,9 @@ serdes/meta:
model: Table
- id: PRODUCT_ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/RATING.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/RATING.yaml
index 3417c5af37d..126ed1bb43a 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/RATING.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/RATING.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: RATING
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/REVIEWER.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/REVIEWER.yaml
index c3dbcc79da8..9c00b9f7a50 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/REVIEWER.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/REVIEWS/fields/REVIEWER.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: REVIEWER
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/ID.yaml
index 09b2e1723b8..d25b9983b5d 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/LAST_LOGIN.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/LAST_LOGIN.yaml
index 4e0136609de..b2a009965ca 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/LAST_LOGIN.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/LAST_LOGIN.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: LAST_LOGIN
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/NAME.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/NAME.yaml
index 925379cbf21..e7bcdd88d12 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/NAME.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/NAME.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: NAME
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/PASSWORD.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/PASSWORD.yaml
index b87da7f9750..32338b81111 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/PASSWORD.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/USERS/fields/PASSWORD.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: PASSWORD
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/CATEGORY_ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/CATEGORY_ID.yaml
index 874329e8b6c..8c3081c5542 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/CATEGORY_ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/CATEGORY_ID.yaml
@@ -41,5 +41,9 @@ serdes/meta:
model: Table
- id: CATEGORY_ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/ID.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/ID.yaml
index f76af549cf4..b966007f61c 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/ID.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/ID.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: ID
model: Field
+database_default: null
database_indexed: true
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LATITUDE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LATITUDE.yaml
index e2c199e1041..4b75e6df7c7 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LATITUDE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LATITUDE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: LATITUDE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LONGITUDE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LONGITUDE.yaml
index aa1a1e51e71..ed8bb3c5762 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LONGITUDE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/LONGITUDE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: LONGITUDE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/NAME.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/NAME.yaml
index b5181bda8ca..73e14e1a84a 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/NAME.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/NAME.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: NAME
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null
diff --git a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/PRICE.yaml b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/PRICE.yaml
index d4bb3906516..f53227be7db 100644
--- a/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/PRICE.yaml
+++ b/test_resources/serialization_baseline/databases/test-data (h2)/schemas/PUBLIC/tables/VENUES/fields/PRICE.yaml
@@ -37,5 +37,9 @@ serdes/meta:
model: Table
- id: PRICE
model: Field
+database_default: null
database_indexed: false
+database_is_generated: null
+database_is_nullable: null
+database_is_pk: null
database_partitioned: null