-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🪟 Apply default sync mode logic to new streams #18451
Merged
teallarson
merged 6 commits into
master
from
teal/apply-default-sync-mode-to-new-streams
Oct 27, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5223fbd
brute force solution
teallarson 1ef7ccf
cleanup
teallarson 3a088cf
testing and comment
teallarson dd66f03
Merge branch 'master' into teal/apply-default-sync-mode-to-new-streams
teallarson 85b7b38
Merge branch 'master' into teal/apply-default-sync-mode-to-new-streams
teallarson 8441f16
review cleanup
teallarson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { SyncSchema, SyncSchemaStream } from "core/domain/catalog"; | ||
import { DestinationSyncMode, SyncMode, AirbyteStreamConfiguration } from "core/request/AirbyteClient"; | ||
import { | ||
DestinationSyncMode, | ||
SyncMode, | ||
AirbyteStreamConfiguration, | ||
StreamDescriptor, | ||
} from "core/request/AirbyteClient"; | ||
|
||
const getDefaultCursorField = (streamNode: SyncSchemaStream): string[] => { | ||
if (streamNode.stream?.defaultCursorField?.length) { | ||
|
@@ -119,18 +124,24 @@ const getOptimalSyncMode = ( | |
const calculateInitialCatalog = ( | ||
schema: SyncSchema, | ||
supportedDestinationSyncModes: DestinationSyncMode[], | ||
isNotCreateMode?: boolean | ||
): SyncSchema => ({ | ||
streams: schema.streams.map<SyncSchemaStream>((apiNode, id) => { | ||
const nodeWithId: SyncSchemaStream = { ...apiNode, id: id.toString() }; | ||
const nodeStream = verifySourceDefinedProperties(verifySupportedSyncModes(nodeWithId), isNotCreateMode || false); | ||
|
||
if (isNotCreateMode) { | ||
return nodeStream; | ||
} | ||
|
||
return getOptimalSyncMode(verifyConfigCursorField(nodeStream), supportedDestinationSyncModes); | ||
}), | ||
}); | ||
isNotCreateMode?: boolean, | ||
newStreamDescriptors?: StreamDescriptor[] | ||
): SyncSchema => { | ||
return { | ||
streams: schema.streams.map<SyncSchemaStream>((apiNode, id) => { | ||
const nodeWithId: SyncSchemaStream = { ...apiNode, id: id.toString() }; | ||
const nodeStream = verifySourceDefinedProperties(verifySupportedSyncModes(nodeWithId), isNotCreateMode || false); | ||
|
||
// if the stream is new since a refresh, we want to verify cursor and get optimal sync modes | ||
const matches = newStreamDescriptors?.some( | ||
(streamId) => streamId.name === nodeStream?.stream?.name && streamId.namespace === nodeStream.stream?.namespace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only contains the identifying information (name and namespace), not the entire stream object. |
||
); | ||
if (isNotCreateMode && !matches) { | ||
return nodeStream; | ||
} | ||
return getOptimalSyncMode(verifyConfigCursorField(nodeStream), supportedDestinationSyncModes); | ||
}), | ||
}; | ||
}; | ||
|
||
export default calculateInitialCatalog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: maybe a matter of preference, but I find negative names for booleans harder to read - in this case I would prefer
!isCreateMode
toisNotCreateMode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this variable is actually defined elsewhere like this, so I see why you used it! No need to change it.