-
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -609,6 +609,30 @@ public void testDescription() { | |
assertEquals(bigQueryExpectedSchema, bigQueryTestSchema); | ||
} | ||
|
||
@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()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
.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 commentThe 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? |
||
|
||
@Test | ||
public void testAllFieldsNullable() { | ||
final String fieldName = "RequiredField"; | ||
|
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.