-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
🪟 🎉 Disable deselection of cursor field/primary key in the UI #20844
Conversation
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.
airbyte-webapp/src/components/connection/CatalogTree/FieldRow.tsx
Outdated
Show resolved
Hide resolved
airbyte-webapp/src/components/connection/CatalogTree/streamConfigHelpers/streamConfigHelpers.ts
Show resolved
Hide resolved
airbyte-webapp/src/components/connection/CatalogTree/streamConfigHelpers/streamConfigHelpers.ts
Outdated
Show resolved
Hide resolved
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.
Code lgtm and tested locally.
I think it would be prudent to add a test case specifically for source-defined cursors and source-defined primary keys not being able to be deselected, but I don't necessarily think it's blocking.
const key = JSON.stringify(selectedFieldInfo.fieldPath); | ||
set.add(key); |
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.
This converts the fieldPath
(e.g. ['path', 'to', 'field']
) into a string (e.g. "[\"path\",\"to\",\"field\"]"
) so that we can add it as a unique value to the set. It gets converted back into an array before returning.
This conversion between String[]
> String
> String[]
might seem expensive, but it allows us use a Set
to avoid duplicates when merging, which avoids a lot of nested comparisons of arrays.
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.
I think that's a reasonable tradeoff. It sounds like it would still be more efficient for a large sync catalog or a sync catalog with a lot of changes than what this was doing before, correct?
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.
Yes, at least as efficient, and in the best case more efficient 👍
Thanks @tealjulia! I made one more minor adjustment here FYI d193819 |
What
Closes #20586
This PR automatically adds special handling of cursor fields and primary keys with regards to field selection in the airbyte UI.
How
useCallback()
functions into pure functions, adds unit tests to cover theseRecommended reading order
FieldRow.tsx
- where the pk & cursor field deselection is disabledCatalogSection.tsx
- whereuseCallback()
logic has been extracted to pure functionsstreamConfigHelpers
- the pure functions that return a new stream config