-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add support for DG-410 Fix doc/defaults in Avro converter #159
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: SajanaW <[email protected]>
|
||
Schema kafkaConnectTestSchema = | ||
SchemaBuilder.struct() | ||
.field(fieldName, SchemaBuilder.string().parameter("io.confluent.connect.avro.field.doc." + fieldName,fieldDoc).build()) |
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.
The Doc will be in the Struct's parameter, not fieldSchema's parameter.
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.
Thanks @SajanaW. I have some concerns about this change and others like it that I've noted in the review.
I'm also wondering if, should we decide this approach is valid, the changes here are sufficient. It looks like all that we're addressing right now are the descriptions of fields in BigQuery; however, the logic for generating a description of the table itself is left unchanged. It looks like this logic uses the same Schema::doc
method that the connector uses for generating field descriptions; do we need to worry about that as well?
Finally, shouldn't we target an earlier branch with this PR since it's a bug fix? The furthest we tend to go back is 1.6.x, but if that presents an unnecessary burden due to merge conflicts 2.0.x would probably be fine.
} else if (kafkaConnectSchema.parameters() != null && | ||
kafkaConnectSchema.parameters().get(AVRO_DOC_PARAMETER + fieldName) != null){ | ||
res.setDescription(kafkaConnectSchema.parameters().get(AVRO_DOC_PARAMETER + fieldName)); |
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.
We're introducing Avro converter-specific logic into the connector here. That doesn't feel right; connectors should be largely agnostic about the converter that they're configured with, with the possible exception of requiring schemas with the data that they process.
If we add this logic here, what's to stop other converter developers from filing similar PRs against this and other connector repos to add more converter-specific logic?
Do you know why the Avro converter was changed in such a way that causes a property that used to be set as the doc of the Connect schema to be set instead as a converter-specific property, leaving the doc blank? The linked PR's description is a little thin and the accompanying issue is pretty lengthy. It'd be nice if you could provide a summary of the motivation for that change (if you're already aware of the rationale), or maybe bring in someone who worked on it to help explain things here.
As things stand right now, I'm hesitant to include this change and think that an adjustment of the converter logic may be warranted in its place.
@Test | ||
public void testDescriptionInField() { | ||
final String fieldName = "WithDoc"; | ||
final String fieldDoc = "test documentation"; | ||
|
||
com.google.cloud.bigquery.Schema bigQueryExpectedSchema = | ||
com.google.cloud.bigquery.Schema.of( | ||
com.google.cloud.bigquery.Field.newBuilder(fieldName, | ||
LegacySQLTypeName.STRING) | ||
.setMode(com.google.cloud.bigquery.Field.Mode.REQUIRED) | ||
.setDescription(fieldDoc) | ||
.build() | ||
); | ||
|
||
Schema kafkaConnectTestSchema = | ||
SchemaBuilder.struct() | ||
.field(fieldName, SchemaBuilder.string().parameter("io.confluent.connect.avro.field.doc." + fieldName,fieldDoc).build()) | ||
.build(); | ||
|
||
com.google.cloud.bigquery.Schema bigQueryTestSchema = | ||
new BigQuerySchemaConverter(false).convertSchema(kafkaConnectTestSchema); | ||
assertEquals(bigQueryExpectedSchema, bigQueryTestSchema); | ||
} |
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.
Should we add another case that ensures backwards compatibility by converting a Connect schema that has both a standard doc and an Avro converter-specific doc property, and verifies that the former is used for the field's description?
Signed-off-by: SajanaW <[email protected]>
@SajanaW do you still plan to pursue this or should we close? |
What
Avro has moved their doc strings from field().doc() to parameters, where the parameter name is
io.confluent.connect.avro.field.doc.
fieldName. To adjust to this, if doc is absent, let's look for this parameter and populate the doc string accordingly.References:
confluentinc/schema-registry#1042
https://github.com/confluentinc/schema-registry/pull/1625/files#