Skip to content

Feature/default and generated columns - #501

Open
aseering wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
aseering:feature/default-and-generated-columns
Open

Feature/default and generated columns#501
aseering wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
aseering:feature/default-and-generated-columns

Conversation

@aseering

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

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.

2 participants