materialize-sql: validations and migrations for only-null columns #2345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
WIP - The necessary plumbing is in place based on the struct updates from the updated flow pin and all existing tests pass. This can't be properly tested without a control plane build that populates
write_inference
though.Handling for fields that have only
null
or no types, in both validate and apply.Columns for these fields can be created based on a present
write_inference
. Schema inference may have only ever observed anull
value, or have never observed a value at all, but we can still make a good guess on what kind of column to create based on the type from the write schema.Similarly, we can always migrate these columns, since we know that they have only ever had
null
values. A possible scenario is this: The write schema hastype: string
, but the source field is almost alwaysnull
(or not present). Eventually a value shows up, but it is inferred as atype: string, format: date-time
. Although aTEXT
column could not typically be migrated to aDATETIME
column, we know all the existing values must benull
so the column can be trivially migrating by dropping & re-creating it with the new type.Workflow steps:
(How does one use this feature, and how has it changed)
Documentation links affected:
(list any documentation links that you created, or existing ones that you've identified as needing updates, along with a brief description)
Notes for reviewers:
(anything that might help someone review this PR)
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)