storage/sql: Refactor subsource purification (prep for source-fed table purification) [ENG-TASK-19] #28310
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.
Motivation
Inspired by & replaces Sean's draft PR #27320 to shuffle when subsource statements are generated.
This PR is prep work for the implementation described in #27907
This PR shouldn't introduce any functional changes -- it is a refactor of subsource purification such that we now generate
CreateSubsourceStatement
s after purification and using the same method in both 'create source' and 'alter source' statements.The intent is to tease apart the purification logic (obtaining state from external systems) from the statement generation logic, such that I can re-use as much of the subsource purification logic as possible to purify & plan
CREATE TABLE .. FROM SOURCE
statements in subsequent PRs.In the spirit of yesterday's cluster-team whiteboard discussions I also cleaned up the naming in much of the purification code.
Tips for reviewer
The first commit is the actual refactor
The 2nd and 3rd commits are a rename of many overloaded structs/variables using the word 'subsource', to clarify whether they were referring to an 'external reference' (e.g. upstream postgres table) or a 'source export' - the object (e.g. either a subsource or table) being exported by a source. This ended up more LOC than expected but clarifying these terms will likely make later PRs easier to grok.
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.