Skip to content
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

Fix enum & set values after COPY phase #92

Merged
merged 1 commit into from
Dec 14, 2023
Merged

Fix enum & set values after COPY phase #92

merged 1 commit into from
Dec 14, 2023

Conversation

notfelineit
Copy link
Contributor

@notfelineit notfelineit commented Dec 13, 2023

This PR addresses https://github.com/planetscale/airbyte-source/issues/56 and adds extra support for mapping ENUM and SET values after the initial COPY phase of replication.

During the replicating phase, we expect enum and set values to appear as their indices ("1") rather than their value ("apple" in a column of type enum('apple','banana','orange')). Because of this, we need extra logic to map them to their actual value before passing the value on to Airbyte.


// Takes enum or set column type like ENUM('a','b','c') or SET('a','b','c')
// and returns a slice of values []string{'a', 'b', 'c'}
func parseEnumOrSetValues(columnType string) []string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting the "parsing" logic here does result in an extra parse on every enum/set column value. If this is too much processing, we could "save" the parsed values somewhere upstream - however, that would require refactoring a great deal more of this code since, as it is currently, we don't pass a lot of metadata around during the READ phase.

Copy link
Contributor

@Phanatic Phanatic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! thanks for fixing this.

@notfelineit notfelineit merged commit 54a459f into main Dec 14, 2023
3 checks passed
@notfelineit notfelineit deleted the fix-enum-sets branch December 14, 2023 01:55
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