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

adapter/storage: Cast MySQL bit columns to uint8, add convience functions #31097

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ParkMyCar
Copy link
Member

@ParkMyCar ParkMyCar commented Jan 17, 2025

This PR changes the MySQL source to support ingesting the bit type as uint8. It also adds two new Postgres functions, bit_count(bytea) and get_bit(bytea, int32) to making working with byte strings easier.

Motivation

Progress towards: https://github.com/MaterializeInc/database-issues/issues/8891

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@ParkMyCar ParkMyCar requested review from a team as code owners January 17, 2025 19:29
@ParkMyCar ParkMyCar requested a review from jkosh44 January 17, 2025 19:29
Copy link
Contributor

@jkosh44 jkosh44 left a comment

Choose a reason for hiding this comment

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

LGTM, but I think we should add docs for the new functions.

@@ -24,7 +24,6 @@ rust_library(
compile_data = [],
crate_features = ["default"],
data = [],
disable_pipelining = True,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to include this in this PR? It seems a bit unrelated.

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't was rebased on the wrong branch by accident, removed!

.get(byte_index)
.map(|b| (*b >> bit_index) & 1)
.ok_or(err)?;
Ok(Datum::from(i32::from(i)))
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm understanding correctly, the following might be useful: assert!(i == 0 || i == 1)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call!

@ParkMyCar
Copy link
Member Author

LGTM, but I think we should add docs for the new functions.

Good idea, I'll add them in a separate PR though so we can merge them when v0.131 goes out

@ParkMyCar ParkMyCar enabled auto-merge (squash) January 17, 2025 19:58
@ParkMyCar ParkMyCar disabled auto-merge January 17, 2025 20:04
@ParkMyCar ParkMyCar changed the title adapter/storage: Cast MySQL bit columns to bytea, add convience functions adapter/storage: Cast MySQL bit columns to uint8, add convience functions Jan 17, 2025
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