-
Feature Request
-
Resolution: Done
-
Optional
-
None
-
None
-
False
-
None
-
False
Feature request or enhancement
Add db comment to schema docs when using debezium connector
Which use case/requirement will be addressed by the proposed feature?
Provide additional information of db to connector schmea
Implementation ideas (optional)
in io.debezium.relational.TableSchemaBuilder class
protected void addField(SchemaBuilder builder, Table table, Column column, ColumnMapper mapper) { final Object defaultValue = column.defaultValueExpression() .flatMap(e -> defaultValueConverter.parseDefaultValue(column, e)) .orElse(null); final SchemaBuilder fieldBuilder = customConverterRegistry.registerConverterFor(table.id(), column, defaultValue) .orElse(valueConverterProvider.schemaBuilder(column)); if (fieldBuilder != null) { if (mapper != null) { // Let the mapper add properties to the schema ... mapper.alterFieldSchema(column, fieldBuilder); } if (column.isOptional()) { fieldBuilder.optional(); } //here //add doc from column comments if (column.comment() != null) { fieldBuilder.doc(column.comment()); } // if the default value is provided if (column.hasDefaultValue() && defaultValue != null) { try { // if the resolution of the default value resulted in null; there is no need to set it // if the column isn't optional, the schema won't be set as such and therefore trying // to set a null default value on a non-optional field schema will assert. fieldBuilder .defaultValue(customConverterRegistry.getValueConverter(table.id(), column) .orElse(ValueConverter.passthrough()).convert(defaultValue)); } catch (SchemaBuilderException e) { throw new DebeziumException("Failed to set field default value for '" + table.id() + "." + column.name() + "' of type " + column.typeName() + ", the default value is " + defaultValue + " of type " + defaultValue.getClass(), e); } } builder.field(fieldNamer.fieldNameFor(column), fieldBuilder.build()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("- field '{}' ({}{}) from column {}", column.name(), builder.isOptional() ? "OPTIONAL " : "", fieldBuilder.type(), column); } } else { LOGGER.warn("Unexpected JDBC type '{}' for column '{}' that will be ignored", column.jdbcType(), column.name()); } }