DBZ-612 Support mongo NULL type

Since we can't trace back the original value since mongo is a
schema-less storage we fallback to string as strategy.
This commit is contained in:
Renato Mefi 2018-11-07 18:55:21 +01:00 committed by Gunnar Morling
parent c5ecff4be6
commit 6e115043ca
2 changed files with 5 additions and 10 deletions

View File

@ -51,12 +51,12 @@ public void convertFieldValue(Entry<String, BsonValue> keyvalueforStruct, Struct
String key = keyvalueforStruct.getKey();
BsonType type = keyvalueforStruct.getValue().getBsonType();
if (type == BsonType.NULL) {
LOG.warn("Field of type NULL is not added to the struct");
return;
}
switch (type) {
case NULL:
colValue = null;
break;
case STRING:
colValue = keyvalueforStruct.getValue().asString().getValue().toString();
break;
@ -233,9 +233,6 @@ public void addFieldSchema(Entry<String, BsonValue> keyValuesforSchema, SchemaBu
switch (type) {
case NULL:
LOG.warn("Data type {} not currently supported", type);
break;
case STRING:
case JAVASCRIPT:
case OBJECT_ID:
@ -321,9 +318,6 @@ public void addFieldSchema(Entry<String, BsonValue> keyValuesforSchema, SchemaBu
switch (valueType) {
case NULL:
LOG.warn("Data type {} not currently supported", valueType);
break;
case STRING:
case JAVASCRIPT:
case OBJECT_ID:

View File

@ -158,6 +158,7 @@ public void shouldProcessNullValue() {
SchemaBuilder.struct().name("withnull")
.field("_id", Schema.OPTIONAL_STRING_SCHEMA)
.field("delivery", SchemaBuilder.struct().name("withnull.delivery").optional()
.field("hour", Schema.OPTIONAL_STRING_SCHEMA)
.field("hourId", Schema.OPTIONAL_INT32_SCHEMA)
.build()
)