-
Notifications
You must be signed in to change notification settings - Fork 4.1k
importccl: IMPORT INTO should support gateway_region builtin default expression #69616
Description
To unlock IMPORT INTO for regional by row tables, it needs to be able to handle the default expression on the crdb_region column which is a call to the crdb builtin gateway_region. This builtin is volatile depending on the gateway node the import job is running on, and thus we do cannot support it as is, since it breaks the idempotency invariant of import execution.
To work around this volatility we can override the gateway_region default expression to always return the primary region of the database that was resolved during import planning. This is similar to what we do during the backfill of the column when altering a table's locality to RBR. Evaluating the default expr to the primary region also seems like the "more correct" thing to do since an import job is not necessarily associated with a gateway node, it is a background process ingesting data.
Today, an IMPORT INTO will fail during type resolution of the underlying UDT of crdb_region, but once #61133 (comment) is addressed we will not run into that particular hurdle.
Epic CRDB-7074