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

Implemented a new id strategy in the Sink Connector #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crossleyjuan
Copy link

Recently I'd a request from my customer where they explained that when the _id is provided in the kafka stream there's no way to convert this to ObjectId to keep it consistent with the other records in the collection, checking the different Id Providers it looks like there's no implementation of the ObjectId when it's provided, as such I've implemented a custom Id Provider that receives the string either in the Key or in the Value and converts this to an ObjectId, this way the customer will keep consistency with the previous records created using standard driver.

…ct id as string in a field and then it will be converted to ObjectId inside the connector
@M3lkior
Copy link

M3lkior commented Mar 9, 2022

hi, thanks for the PR @crossleyjuan , we have exactly the same need / constraints in our actual product.

Any guys in the mongodb core team can evaluate this pr / need ?

@fabienOuedraogo
Copy link

@crossleyjuan That's really great !! Waiting to be merged :)

@@ -0,0 +1,20 @@
# MongoDB Kafka BsonObjectId

This implementaion allows the MongoDB Kafka sink connector to convert an existing _id that is string as ObjectId

Choose a reason for hiding this comment

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

Suggested change
This implementaion allows the MongoDB Kafka sink connector to convert an existing _id that is string as ObjectId
This implementation allows the MongoDB Kafka sink connector to convert an existing _id that is string as ObjectId

VALUE
}

private ProvidedIn where;

Choose a reason for hiding this comment

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

Suggested change
private ProvidedIn where;
private final ProvidedIn where;

@wesleysantos-ws
Copy link

Hi there,
Any chance this PR could be reviewed soon?


abstract class BsonOidProvidedStrategy implements IdStrategy {

protected enum ProvidedIn {

Choose a reason for hiding this comment

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

What about headers?

() ->
new DataException(
"Provided id strategy is used but the document structure either contained"
+ " no _id field or it was null"));

Choose a reason for hiding this comment

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

clarify: no top-level field

@belldoor
Copy link

belldoor commented Sep 1, 2023

Hi team,
Any chance this PR could be reviewed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants