Skip to content

Feature/default and generated columns - #501

Merged
prernakakkar-google merged 4 commits into
GoogleCloudPlatform:mainfrom
aseering:feature/default-and-generated-columns
Aug 14, 2026
Merged

Feature/default and generated columns#501
prernakakkar-google merged 4 commits into
GoogleCloudPlatform:mainfrom
aseering:feature/default-and-generated-columns

Conversation

@aseering

Copy link
Copy Markdown
Collaborator

I thought I had posted this months ago but it seemingly got lost somewhere, apologies!

This change updates the data ingestion logic. For Spanner:

  • When computing the set of columns to load data into, generated columns are now ignored
  • Default columns aren't ignored (because loading data into them is valid but optional), but we reserve a couple special keyword names that schemas can use for default ID columns and the loader won't try to populate them

The underlying problem is as follows: Spanner requires that all tables contain a PK, and that all PK values be unique. Some of our datasets do not guarantee uniqueness. The recommended workaround in this case is to construct a synthetic column where each row is a UUID, or a value from a sequence, or otherwise some synthetic and guaranteed-unique value. (Then just ignore this column; let Spanner manage and use it itself.)

Some of our schemas do this. Which is fine.

The issue then is, the data loader tries to populate all columns on the table, and it errors out if it can't do so. Populating generated columns with data from a .csv file isn't a correct thing to do. (They're generated and managed by the database; they're not allowed to be provided by the user.) Populating columns with a DEFAULT clause is permissible, but not required, and not desired for this use case. This PR adds some logic to enable those use cases.

IsmailMehdi
IsmailMehdi previously approved these changes Jul 18, 2026
@IsmailMehdi

Copy link
Copy Markdown
Collaborator

@aseering
aseering force-pushed the feature/default-and-generated-columns branch from b1fa052 to ae33933 Compare August 12, 2026 19:08
@aseering
aseering force-pushed the feature/default-and-generated-columns branch from ae33933 to abe01c9 Compare August 12, 2026 21:00
@aseering

Copy link
Copy Markdown
Collaborator Author

Fixed the pycodestyle issues.

Could someone with access please do a /gcbrun?

@prernakakkar-google

Copy link
Copy Markdown
Collaborator

/gcbrun

@prernakakkar-google
prernakakkar-google merged commit a338eab into GoogleCloudPlatform:main Aug 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants